Prefs class
Save and load data locally.
After initializing and initializing the data, get and save the data.
await Prefs.initialize();
final data = Prefs.get("key");
Prefs.set( "test", "data" );
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
- isInitialized → bool
-
True if the data has been initialized.
no setter
-
keys
→ Set<
String> -
Get all stored keys.
no setter
Static Methods
-
clear(
) → void - Initialize the data.
-
containsKey(
String key) → bool - Check if data exists.
-
get<
T> (String key, [T? defaultValue]) → T? - Get the data.
-
getBool(
String key, [bool defaultValue = false]) → bool - Get the data as bool.
-
getDouble(
String key, [double defaultValue = 0.0]) → double - Get the data.
-
getInt(
String key, [int defaultValue = 0]) → int - Get the data as int.
-
getString(
String key, [String defaultValue = ""]) → String - Get the data as String.
-
getStringList(
String key, [List< String> defaultValue = const []]) → List<String> - Get the data as list of String.
-
initialize(
) → Future< void> - Initialize the data.
-
reload(
) → Future< void> - Update data.
-
remove(
String key) → void -
Delete
key
from data. -
set(
String key, dynamic value) → void - Save the data.