LocalStorage class
A utility class for managing state in the browser localStorage
.
Provides a typed interface for saving and loading JSON-serializable data. All keys are automatically prefixed to avoid collisions with other data stored on the same domain. The prefix is generated based on the application's URL path.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
clear(
) → void - Removes all keys associated with this application's prefix.
-
delete(
String key) → void -
Deletes a value from local storage for the given
key
. -
getAllKeys(
) → List< String> - Returns a list of all keys stored by this utility, without the prefix.
-
load<
T> (String key, [T? defaultValue]) → T? -
Loads a value of type
T
from local storage. -
save<
T> (String key, T value) → void -
Saves a value to local storage with the given
key
.