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 true if an entry for key exists (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, or null if 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 key and deserialises it using fromJson. Returns null if 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 value under key, overwriting any existing entry.
writeJson<T>(String key, T value, Map<String, dynamic> toJson(T value)) Future<void>
Serialises value to JSON using toJson and persists it under key.

Operators

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