JsonFilePersister<T> class

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

Constructors

JsonFilePersister([String? path])
Creates a new instance of the persistence.

Properties

hashCode int
The hash code for this object.
no setterinherited
path String?
Gets the file path where data is stored.
getter/setter pair
path_ String?
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

configure(ConfigParams config) → void
Configures component by passing configuration parameters.
load(String? correlation_id) Future<List<T>>
Loads data items from external JSON file.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent 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