SharedPreferencesSnapshotStorage class
SharedPreferences-based storage implementation for snapshots.
This implementation saves snapshots using SharedPreferences, which works across all platforms including web. Each snapshot is saved as a JSON string with a key prefix.
Example:
final storage = SharedPreferencesSnapshotStorage();
// Save a snapshot
await storage.save(snapshot, 'my_snapshot');
// Load a snapshot
final loaded = await storage.load('my_snapshot');
Key Naming:
- Keys are prefixed with 'checkpoint_' to avoid conflicts
- If a key is provided, it's stored as 'checkpoint_{key}'
- If no key is provided, the default key is used
Platform Support:
- ✅ Web
- ✅ Android
- ✅ iOS
- ✅ macOS
- ✅ Windows
- ✅ Linux
- Implemented types
Constructors
- Creates a SharedPreferences-based snapshot storage.
Properties
- defaultKey → String
-
The default key used when no key is specified.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- keyPrefix → String
-
Prefix for all storage keys.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → Future< void> -
Clears all snapshots from storage.
override
-
delete(
String key) → Future< bool> -
Deletes a snapshot from storage.
override
-
listKeys(
) → Future< List< String> > -
Lists all available snapshot keys.
override
-
load(
[String? key]) → Future< Snapshot?> -
Loads a snapshot from storage.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
save(
Snapshot snapshot, [String? key]) → Future< void> -
Saves a snapshot to storage.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited