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 a bool.
getDouble(String name, [double? defaultValue]) double?
Get name as a double.
getInt(String name, [int? defaultValue]) int?
Get name as a int.
getString(String name, [String? defaultValue]) String?
Get name as a String.
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 given value.
setBool(String name, bool value) → void
Set the given key name to the given value.
setDouble(String name, double value) → void
Set the given key name to the given value.
setInt(String name, int value) → void
Set the given key name to the given value.
setString(String name, String value) → void
Set the given key name to the given value.
toString() String
A string representation of this object.
inherited

Operators

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