PlayxPrefsWithCache class abstract
Provides a persistent store for simple data with caching capabilities.
This class is a wrapper around SharedPreferencesWithCache, allowing for synchronous
data retrieval through a cache. It provides methods for storing and retrieving
various data types such as String, int, double, and bool.
If preferences on the platform may be altered by other means than through this instance, consider using PlayxAsyncPrefs instead. You may also refresh the cached data using reloadCache prior to a get request to prevent missed changes that may have occurred since the cache was last updated.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
Getter for the SharedPreferencesWithCache instance.
no setter
Static Methods
-
clear(
) → Future< void> - Clears all data in the shared preferences.
-
create(
{SharedPreferencesWithCacheOptions options = const SharedPreferencesWithCacheOptions()}) → Future< SharedPreferencesWithCache> -
Creates a new instance of SharedPreferencesWithCache with the given
optionsand reloads the cache from the platform data. -
dispose(
) → Future< void> - Disposes the SharedPreferencesWithCache instance.
-
find(
String key) → Object? -
Finds and returns the value associated with the given
keyas anObject. -
getBool(
String key, {bool fallback = false}) → bool -
Retrieves the value associated with the given
keyas abool. -
getDouble(
String key, {double fallback = -1}) → double -
Retrieves the value associated with the given
keyas adouble. -
getInt(
String key, {int fallback = -1}) → int -
Retrieves the value associated with the given
keyas anint. -
getString(
String key, {String fallback = ''}) → String -
Retrieves the value associated with the given
keyas aString. -
maybeGetBool(
String key) → bool? -
Retrieves the value associated with the given
keyas abool. -
maybeGetDouble(
String key) → double? -
Retrieves the value associated with the given
keyas adouble. -
maybeGetInt(
String key) → int? -
Retrieves the value associated with the given
keyas anint. -
maybeGetString(
String key) → String? -
Retrieves the value associated with the given
keyas aString. -
reloadCache(
) → Future< void> - Updates the cache with the latest values from the platform.
-
remove(
String key) → Future< void> -
Removes the value associated with the given
key. -
setBool(
String key, bool value) → Future< void> -
Sets the value associated with the given
keyas abool. -
setDouble(
String key, double value) → Future< void> -
Sets the value associated with the given
keyas adouble. -
setInt(
String key, int value) → Future< void> -
Sets the value associated with the given
keyas anint. -
setString(
String key, String value) → Future< void> -
Sets the value associated with the given
keyas aString.