JustStandardStorage class abstract
Interface for non-sensitive, persistent key-value storage.
The default implementation is FileStorage, which persists data as an
atomic plain-JSON file using only dart:io.
Use JustStorage.standard to obtain an instance — no path_provider
import required in your app:
final JustStandardStorage storage = await JustStorage.standard();
Register in a DI container (e.g. get_it):
sl.registerLazySingleton<JustStandardStorage>(
() => await JustStorage.standard(),
);
- Implementers
Constructors
- JustStandardStorage()
-
Default constructor for subclasses.
const
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
-
clear(
) → Future< void> - Removes all entries managed by this storage instance.
-
containsKey(
String key) → Future< bool> -
Returns
trueif an entry forkeyexists (even if the value is empty). -
delete(
String key) → Future< void> -
Removes the entry for
key. No-op if the key does not exist. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
read(
String key) → Future< String?> -
Returns the raw string stored under
key, ornullif absent. -
readAll(
) → Future< Map< String, String> > - Returns all key-value pairs currently in the store as an unmodifiable map.
-
readJson<
T> (String key, T fromJson(Map< String, dynamic> json)) → Future<T?> -
Reads the stored JSON string for
keyand deserialises it usingfromJson. Returnsnullif the key is absent or the stored value cannot be parsed. -
toString(
) → String -
A string representation of this object.
inherited
-
watch(
String key) → Stream< String?> - Returns a broadcast Stream that emits:
-
write(
String key, String value) → Future< void> -
Persists
valueunderkey, overwriting any existing entry. -
writeJson<
T> (String key, T value, Map< String, dynamic> toJson(T value)) → Future<void> -
Serialises
valueto JSON usingtoJsonand persists it underkey.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited