LocalStorage class
Creates instance of a local storage. Key is used as a filename
Constructors
-
LocalStorage(String key, [String? path, Map<
String, dynamic> ? initialData]) -
key
is used as a filename Optionalpath
is used as a directory. Defaults to application document directoryfactory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
onError
↔ ValueNotifier<
Error> -
ValueNotifier which notifies about errors during storage initialization
getter/setter pair
-
ready
↔ Future<
bool> -
A future indicating if localstorage instance is ready for read/write operations
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
Map< String, dynamic> > -
no setter
Methods
-
clear(
) → Future< void> - Removes all items from localstorage
-
deleteItem(
String key) → Future< void> - Removes item from storage by key
-
dispose(
) → void -
getItem(
String key) → dynamic - Returns a value from storage by key
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setItem(
String key, dynamic value, [Object toEncodable(Object nonEncodable)?]) → Future< void> -
Saves item by
key
to a storage. Value should be json encodable (json.encode()
is called under the hood). After item was set to storage, consecutive getItem will returnjson
representation of this item iftoEncodable
is provided, it is called before setting item to storage otherwisevalue.toJson()
is called -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited