SharedPreferencesWithCache class
Provides a persistent store for simple data.
Cache provided to allow for synchronous gets.
If preferences on the platform may be altered by other means than through this instance, consider using SharedPreferencesAsync 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.
- Annotations
Properties
Methods
-
clear(
) → Future< void> - Clears cache and platform preferences that match filter options.
-
containsKey(
String key) → bool -
Returns true if cache contains the given
key
. -
get(
String key) → Object? - Reads a value of any type from the cache.
-
getBool(
String key) → bool? - Reads a value from the cache, throwing a TypeError if the value is not a bool.
-
getDouble(
String key) → double? - Reads a value from the cache, throwing a TypeError if the value is not a double.
-
getInt(
String key) → int? - Reads a value from the cache, throwing a TypeError if the value is not an int.
-
getString(
String key) → String? - Reads a value from the cache, throwing a TypeError if the value is not a String.
-
getStringList(
String key) → List< String> ? - Reads a list of string values from the cache, throwing an exception if it's not a string list.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reloadCache(
) → Future< void> - Updates cache with latest values from platform.
-
remove(
String key) → Future< void> - Removes an entry from cache and platform.
-
setBool(
String key, bool value) → Future< void> -
Saves a boolean
value
to the cache and platform. -
setDouble(
String key, double value) → Future< void> -
Saves a double
value
to the cache and platform. -
setInt(
String key, int value) → Future< void> -
Saves an integer
value
to the cache and platform. -
setString(
String key, String value) → Future< void> -
Saves a string
value
to the cache and platform. -
setStringList(
String key, List< String> value) → Future<void> -
Saves a list of strings
value
to the cache and platform. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
create(
{required SharedPreferencesWithCacheOptions cacheOptions, Map< String, Object?> ? cache}) → Future<SharedPreferencesWithCache> - Creates a new instance with the given options and reloads the cache from the platform data.