SharedPrefUtils class
A utility class that wraps saving and retrieving simple data
(integers, booleans, doubles, strings, and string lists) from
SharedPreferences. This provides a persistent local storage solution
for storing key-value pairs across app sessions.
Constructors
Properties
-
boolKeys
→ Map<
String, bool> -
final
-
doubleKeys
→ Map<
String, double> -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
intKeys
→ Map<
String, int> -
Default values for various types of keys.
final
- prefs ↔ SharedPreferences
-
An instance of
SharedPreferencesfor storing and retrieving data.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
A flag to track whether shared preferences have been initialized.
getter/setter pair
-
stringKeys
→ Map<
String, String> -
final
-
stringListKeys
→ Map<
String, List< String> > -
final
Methods
-
Ensures that the
SharedPreferencesinstance has been initialized. -
get(
String key) → Future -
Retrieves the value for a given key from
SharedPreferences. -
getBool(
String key) → Future< bool> -
Retrieves a boolean value from
SharedPreferences. -
getDouble(
String key) → Future< double> -
Retrieves a double value from
SharedPreferences. -
getInt(
String key) → Future< int> -
Retrieves an integer value from
SharedPreferences. -
getString(
String key) → Future< String> -
Retrieves a string value from
SharedPreferences. -
getStringList(
String key) → Future< List< String> > -
Retrieves a list of strings from
SharedPreferences. -
init(
) → Future< void> -
Initializes the
SharedPreferencesinstance asynchronously. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
set(
String key, dynamic value) → Future< void> -
Sets the value for a given key in
SharedPreferences. -
setBool(
String key, bool value) → Future< void> -
Stores a boolean value in
SharedPreferences. -
setDouble(
String key, double value) → Future< void> -
Stores a double value in
SharedPreferences. -
setInt(
String key, int value) → Future< void> -
Stores an integer value in
SharedPreferences. -
setString(
String key, String value) → Future< void> -
Stores a string value in
SharedPreferences. -
setStringList(
String key, List< String> value) → Future<void> -
Stores a list of strings in
SharedPreferences. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited