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

sharedPrefs SharedPreferences
Returns the initialized SharedPreferences instance.
no setter

Static Methods

clear() Future<void>
Clears all stored preferences.
create() Future<SharedPreferences>
Initializes the SharedPreferences instance.
dispose() Future<void>
Disposes the SharedPreferences instance`.
find(String key) Object?
Returns the shared preferences value for the given key as an Object, or null if it doesn't exist.
getBool(String key, {bool fallback = false}) bool
Returns the shared preferences value for the given key as a non-null bool, or fallback (defaults to false) if it doesn't exist.
getDouble(String key, {double fallback = -1}) double
Returns the shared preferences value for the given key as a non-null double, or fallback (defaults to -1.0) if it doesn't exist.
getInt(String key, {int fallback = -1}) int
Returns the shared preferences value for the given key as a non-null int, or fallback (defaults to -1) if it doesn't exist.
getString(String key, {String fallback = ''}) String
Returns the shared preferences value for the given key as a String, or fallback (defaults to an empty string) if it doesn't exist.
maybeGetBool(String key) bool?
Returns the shared preferences value for the given key as a bool, or null if it doesn't exist.
maybeGetDouble(String key) double?
Returns the shared preferences value for the given key as a double, or null if it doesn't exist.
maybeGetInt(String key) int?
Returns the shared preferences value for the given key as an int, or null if it doesn't exist.
maybeGetString(String key) String?
Returns the shared preferences value for the given key as a String, or null if 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 key to the provided value of type bool.
setDouble(String key, double value) Future<void>
Sets the shared preferences value for the given key to the provided value of type double.
setInt(String key, int value) Future<void>
Sets the shared preferences value for the given key to the provided value of type int.
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 key to the provided value of type String.