PrfDuration class
A type-safe wrapper for storing and retrieving Duration values in SharedPreferences.
This class automatically handles the conversion between Duration objects and their integer representation (microseconds) for storage.
Use this class for storing time intervals, timeouts, animation durations, or any duration-related data.
Example:
final timeout = PrfDuration('request_timeout', defaultValue: Duration(seconds: 30));
await timeout.set(Duration(seconds: 60));
final duration = await timeout.get(); // Duration(seconds: 60)
- Inheritance
-
- Object
- PrfVariable<
Duration> - PrfEncoded<
Duration, int> - PrfDuration
Constructors
- PrfDuration.new(String key, {Duration? defaultValue})
-
Creates a new Duration preference variable with the specified
key
.
Properties
- defaultValue → Duration?
-
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(
SharedPreferencesAsync prefs) → Future< Duration?> -
Retrieves the current value from cache or SharedPreferences.
inherited
-
isValueNull(
SharedPreferencesAsync 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(
SharedPreferencesAsync prefs) → Future< void> -
Removes the value from both the cache and SharedPreferences.
inherited
-
setValue(
SharedPreferencesAsync prefs, Duration value) → Future< void> -
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