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 optional defaultValue.

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<T>, provided by the PrfVariableExtensions extension

Checks if the key exists in SharedPreferences.
get() Future<T?>

Available on PrfVariable<T>, provided by the PrfVariableExtensions extension

Gets the stored value associated with this variable.
getOrFallback(T fallback) Future<T>

Available on PrfVariable<T>, provided by the PrfVariableExtensions extension

Gets the stored value or returns a fallback if the value is null.
getValue(SharedPreferencesAsync prefs) Future<T?>
Retrieves the current value from cache or SharedPreferences.
isNull() Future<bool>

Available on PrfVariable<T>, provided by the PrfVariableExtensions extension

Checks if the current value is null in storage.
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<T>, provided by the PrfVariableExtensions extension

Removes the value from persistent storage.
removeValue(SharedPreferencesAsync prefs) Future<void>
Removes the value from both the cache and SharedPreferences.
set(T value) Future<void>

Available on PrfVariable<T>, provided by the PrfVariableExtensions extension

Sets the value for this variable in persistent storage.
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