PlayxPrefs class abstract
Wrapper for handling shared preferences to save and retrieve data.
This class provides an easy interface for storing and retrieving primitive
data types such as String, int, double, and bool in shared preferences.
It also includes methods to clear and remove specific preferences.
This class will be deprecated in the future in favor of PlayxAsyncPrefs and PlayxPrefsWithCache.
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
-
Returns the initialized
SharedPreferencesinstance.no setter
Static Methods
-
clear(
) → Future< void> - Clears all stored preferences.
-
create(
) → Future< SharedPreferences> - Initializes the SharedPreferences instance.
-
dispose(
) → Future< void> -
Disposes the
SharedPreferencesinstance`. -
find(
String key) → Object? -
Returns the shared preferences value for the given
keyas anObject, ornullif it doesn't exist. -
getBool(
String key, {bool fallback = false}) → bool -
Returns the shared preferences value for the given
keyas a non-nullbool, orfallback(defaults tofalse) if it doesn't exist. -
getDouble(
String key, {double fallback = -1}) → double -
Returns the shared preferences value for the given
keyas a non-nulldouble, orfallback(defaults to -1.0) if it doesn't exist. -
getInt(
String key, {int fallback = -1}) → int -
Returns the shared preferences value for the given
keyas a non-nullint, orfallback(defaults to -1) if it doesn't exist. -
getString(
String key, {String fallback = ''}) → String -
Returns the shared preferences value for the given
keyas aString, orfallback(defaults to an empty string) if it doesn't exist. -
maybeGetBool(
String key) → bool? -
Returns the shared preferences value for the given
keyas abool, ornullif it doesn't exist. -
maybeGetDouble(
String key) → double? -
Returns the shared preferences value for the given
keyas adouble, ornullif it doesn't exist. -
maybeGetInt(
String key) → int? -
Returns the shared preferences value for the given
keyas anint, ornullif it doesn't exist. -
maybeGetString(
String key) → String? -
Returns the shared preferences value for the given
keyas aString, ornullif it doesn't exist. -
remove(
String key) → Future< void> -
Removes the preference with the given
key. -
setBool(
String key, bool value) → Future< void> -
Sets the shared preferences value for the given
keyto the providedvalueof typebool. -
setDouble(
String key, double value) → Future< void> -
Sets the shared preferences value for the given
keyto the providedvalueof typedouble. -
setInt(
String key, int value) → Future< void> -
Sets the shared preferences value for the given
keyto the providedvalueof typeint. -
setMockInitialValues(
Map< String, Object> values) → void - Sets mock initial values for testing purposes.
-
setString(
String key, String value) → Future< void> -
Sets the shared preferences value for the given
keyto the providedvalueof typeString.