SharedPreferencesAsync class

Provides a persistent store for simple data.

Data is persisted to and fetched from the disk asynchronously. If synchronous access to preferences in a locally cached version of preferences is preferred, consider using SharedPreferencesWithCache instead.

Annotations

Constructors

SharedPreferencesAsync({SharedPreferencesOptions options = const SharedPreferencesOptions()})
Creates a new instance with the given options.

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

clear({Set<String>? allowList}) Future<void>
Clears all preferences from the platform.
containsKey(String key) Future<bool>
Returns true if the the platform contains the given key.
getAll({Set<String>? allowList}) Future<Map<String, Object?>>
Returns all keys and values on the the platform that match provided parameters.
getBool(String key) Future<bool?>
Reads a value from the platform, throwing a TypeError if the value is not a bool.
getDouble(String key) Future<double?>
Reads a value from the platform, throwing a TypeError if the value is not a double.
getInt(String key) Future<int?>
Reads a value from the platform, throwing a TypeError if the value is not an int.
getKeys({Set<String>? allowList}) Future<Set<String>>
Returns all keys on the the platform that match provided parameters.
getString(String key) Future<String?>
Reads a value from the platform, throwing a TypeError if the value is not a String.
getStringList(String key) Future<List<String>?>
Reads a list of string values from the platform, throwing a TypeError if the value not a List
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove(String key) Future<void>
Removes an entry from the platform.
setBool(String key, bool value) Future<void>
Saves a boolean value to the platform.
setDouble(String key, double value) Future<void>
Saves a double value to the platform.
setInt(String key, int value) Future<void>
Saves an integer value to the platform.
setString(String key, String value) Future<void>
Saves a string value to the platform.
setStringList(String key, List<String> value) Future<void>
Saves a list of strings value to the platform.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited