PrfBytes class
A type-safe wrapper for storing and retrieving binary data (Uint8List) in SharedPreferences.
This class automatically handles the conversion between binary data and base64 encoded strings for storage in SharedPreferences.
Use this class for storing binary data like images, cryptographic keys, or any other raw byte content.
Example:
final imageData = PrfBytes('profile_image');
await imageData.set(Uint8List.fromList([...]));
final bytes = await imageData.get();
- Inheritance
-
- Object
- PrfVariable<
Uint8List> - PrfEncoded<
Uint8List, String> - PrfBytes
Constructors
- PrfBytes.new(String key, {Uint8List? defaultValue})
-
Creates a new bytes preference variable with the specified
key
.
Properties
- defaultValue → Uint8List?
-
Default value to use when no value is stored yet.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → String
-
Unique key used to store this variable in SharedPreferences.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getValue(
SharedPreferences prefs) → Future< Uint8List?> -
Retrieves the current value from cache or SharedPreferences.
inherited
-
isValueNull(
SharedPreferences prefs) → Future< bool> -
Checks if the current value is null.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeValue(
SharedPreferences prefs) → Future< void> -
Removes the value from both the cache and SharedPreferences.
inherited
-
setValue(
SharedPreferences prefs, Uint8List value) → Future< bool> -
Saves a new value to SharedPreferences and updates the cache.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited