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 Optional path is used as a directory. Defaults to application document directory
factory

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 return json representation of this item if toEncodable is provided, it is called before setting item to storage otherwise value.toJson() is called
toString() String
A string representation of this object.
inherited

Operators

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