SharedPreferences class

Wraps NSUserDefaults (on iOS) and SharedPreferences (on Android), providing a persistent store for simple data.

Data is persisted to disk asynchronously.

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

clear() Future<bool>
Completes with true once the user preferences for the app has been cleared.
commit() Future<bool>
Always returns true. On iOS, synchronize is marked deprecated. On Android, we commit every set.
containsKey(String key) bool
Returns true if persistent storage the contains the given key.
get(String key) → dynamic
Reads a value of any type from persistent storage.
getBool(String key) bool
Reads a value from persistent storage, throwing an exception if it's not a bool.
getDouble(String key) double
Reads a value from persistent storage, throwing an exception if it's not a double.
getInt(String key) int
Reads a value from persistent storage, throwing an exception if it's not an int.
getKeys() Set<String>
Returns all keys in the persistent storage.
getString(String key) String
Reads a value from persistent storage, throwing an exception if it's not a String.
getStringList(String key) List<String>
Reads a set of string values from persistent storage, throwing an exception if it's not a string set.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
reload() Future<void>
Fetches the latest values from the host platform. [...]
remove(String key) Future<bool>
Removes an entry from persistent storage.
setBool(String key, bool value) Future<bool>
Saves a boolean value to persistent storage in the background. [...]
setDouble(String key, double value) Future<bool>
Saves a double value to persistent storage in the background. [...]
setInt(String key, int value) Future<bool>
Saves an integer value to persistent storage in the background. [...]
setString(String key, String value) Future<bool>
Saves a string value to persistent storage in the background. [...]
setStringList(String key, List<String> value) Future<bool>
Saves a list of strings value to persistent storage in the background. [...]
toString() String
A string representation of this object. [...]
inherited

Operators

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

Static Methods

getInstance() Future<SharedPreferences>
Loads and parses the SharedPreferences for this app from disk. [...]
setMockInitialValues(Map<String, dynamic> values) → void
Initializes the shared preferences with mock values for testing. [...]