JsonFilePersister<T> class
Null safety
Persistence component that loads and saves data from/to flat file.
It is used by FilePersistence, but can be useful on its own.
Configuration parameters
- path: path to the file where data is stored
Example
var persister = JsonFilePersister("./data/data.json");
await persister.save("123", ["A", "B", "C"]);
...
var items = await persister.load("123");
print(items); // Result: ["A", "B", "C"]
- Implemented types
-
- ILoader<
T> - ISaver<
T> - IConfigurable
- ILoader<
Constructors
- JsonFilePersister([String? path])
- Creates a new instance of the persistence.
Properties
Methods
-
configure(
ConfigParams config) → void -
Configures component by passing configuration parameters.
override
-
load(
String? correlation_id) → Future< List< T> > -
Loads data items from external JSON file.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
-
save(
String? correlation_id, List< T?> items) → Future -
Saves given data items to external JSON file.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited