FileSnapshotStorage class

File-based storage implementation for snapshots.

This implementation saves snapshots as JSON files in a directory. Each snapshot is saved as a separate file, named by its key or timestamp.

Example:

final storage = FileSnapshotStorage(
  directory: Directory('/path/to/snapshots'),
);

// Save a snapshot
await storage.save(snapshot, 'my_snapshot');

// Load a snapshot
final loaded = await storage.load('my_snapshot');

File Naming:

  • If a key is provided, the file is named {key}.json
  • If no key is provided, the file is named snapshot_{timestamp}.json
  • Files are stored in the specified directory
Implemented types

Constructors

FileSnapshotStorage({required Directory directory, String defaultKey = 'latest'})
Creates a file-based snapshot storage.

Properties

defaultKey String
The default key used when no key is specified.
final
directory Directory
The directory where snapshots are stored.
final
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>
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