Persistable<T> class
abstract
A base class that enables model objects to be:
- Converted to/from JSON
- Saved and loaded from local storage
- Serialized safely with write locking
Your model (e.g., BigState) must implement: Map<String, dynamic> toJson(); T fromString(String jsonString);
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
-
fromString(
String jsonString) → T - Restore an object from a JSON string. Implemented by child classes.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readStringLocally(
) → Future< String?> - Reads the saved JSON string from local storage.
-
saveStringLocally(
String value) → Future< void> - Saves the model's serialized JSON string to local storage. Ensures only one write happens at a time (simple async lock).
-
toJson(
) → Map< String, dynamic> - Convert the model to JSON. Implemented by child classes.
-
toString(
) → String -
JSON string representation of the model.
This is what gets written to disk.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited