PrfVariable<T> class
Base class for all prf persistence variables.
Handles the core functionality for storing, retrieving, and caching values
of type T
in SharedPreferences. This serves as the foundation for all
type-specific prf implementations.
- Implementers
- Available extensions
Constructors
-
PrfVariable.new(String key, SharedPrefsGetter<
T> _getter, SharedPrefsSetter<T> _setter, T? defaultValue) -
Creates a new PrfVariable with the specified
key
, getter, setter, and optionaldefaultValue
.
Properties
- defaultValue → T?
-
Default value to use when no value is stored yet.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → String
-
Unique key used to store this variable in SharedPreferences.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
existsOnPrefs(
) → Future< bool> -
Available on PrfVariable<
Checks if the key exists in SharedPreferences.T> , provided by the PrfVariableExtensions extension -
get(
) → Future< T?> -
Available on PrfVariable<
Gets the stored value associated with this variable.T> , provided by the PrfVariableExtensions extension -
getOrFallback(
T fallback) → Future< T> -
Available on PrfVariable<
Gets the stored value or returns a fallback if the value is null.T> , provided by the PrfVariableExtensions extension -
getValue(
SharedPreferencesAsync prefs) → Future< T?> - Retrieves the current value from cache or SharedPreferences.
-
isNull(
) → Future< bool> -
Available on PrfVariable<
Checks if the current value is null in storage.T> , provided by the PrfVariableExtensions extension -
isValueNull(
SharedPreferencesAsync prefs) → Future< bool> - Checks if the current value is null.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
remove(
) → Future< void> -
Available on PrfVariable<
Removes the value from persistent storage.T> , provided by the PrfVariableExtensions extension -
removeValue(
SharedPreferencesAsync prefs) → Future< void> - Removes the value from both the cache and SharedPreferences.
-
set(
T value) → Future< void> -
Available on PrfVariable<
Sets the value for this variable in persistent storage.T> , provided by the PrfVariableExtensions extension -
setValue(
SharedPreferencesAsync prefs, T value) → Future< void> - Saves a new value to SharedPreferences and updates the cache.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited