Preferences class
A class to save and return items to a preferences dictionary.
Constructors
- Preferences({required File file, String key = defaultPreferencesKey})
- Create an instance.
Properties
-
cache
→ Map<
String, Object?> -
Get cached data.
no setter
- file → File
-
The file where preferences should be stored.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → String
-
The key where preferences will be saved and accessed from.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
String name) → void -
Clear the value at the given
name
. -
get<
T> (String name, [T? defaultValue]) → T? -
Get the given
name
from the cache. -
getBool(
String name, [bool? defaultValue]) → bool? -
Get
name
as abool
. -
getDouble(
String name, [double? defaultValue]) → double? -
Get
name
as adouble
. -
getInt(
String name, [int? defaultValue]) → int? -
Get
name
as aint
. -
getString(
String name, [String? defaultValue]) → String? -
Get
name
as aString
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
save(
) → void - Save the preferences.
-
set(
String name, Object value) → void -
Set the given
name
to the givenvalue
. -
setBool(
String name, bool value) → void -
Set the given key
name
to the givenvalue
. -
setDouble(
String name, double value) → void -
Set the given key
name
to the givenvalue
. -
setInt(
String name, int value) → void -
Set the given key
name
to the givenvalue
. -
setString(
String name, String value) → void -
Set the given key
name
to the givenvalue
. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited