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

sharedPrefs SharedPreferencesWithCache
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 options and 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 key as an Object.
getBool(String key, {bool fallback = false}) bool
Retrieves the value associated with the given key as a bool.
getDouble(String key, {double fallback = -1}) double
Retrieves the value associated with the given key as a double.
getInt(String key, {int fallback = -1}) int
Retrieves the value associated with the given key as an int.
getString(String key, {String fallback = ''}) String
Retrieves the value associated with the given key as a String.
maybeGetBool(String key) bool?
Retrieves the value associated with the given key as a bool.
maybeGetDouble(String key) double?
Retrieves the value associated with the given key as a double.
maybeGetInt(String key) int?
Retrieves the value associated with the given key as an int.
maybeGetString(String key) String?
Retrieves the value associated with the given key as a String.
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 key as a bool.
setDouble(String key, double value) Future<void>
Sets the value associated with the given key as a double.
setInt(String key, int value) Future<void>
Sets the value associated with the given key as an int.
setString(String key, String value) Future<void>
Sets the value associated with the given key as a String.