load method

  1. @override
Future<Snapshot?> load([
  1. String? key
])
override

Loads a snapshot from storage.

Parameters:

  • key: Optional key/identifier for the snapshot. If not provided, the default/latest snapshot will be loaded.

Returns: A Future that completes with the loaded Snapshot, or null if no snapshot exists for the given key.

Throws:

  • FormatException if the stored data is invalid
  • Storage-specific exceptions (e.g., IOException for file storage)

Implementation

@override
Future<Snapshot?> load([String? key]) async {
  final storageKey = key ?? defaultKey;
  final snapshot = _storage[storageKey];
  if (snapshot != null) {
    debugPrint(
      '[Checkpoint] Loaded snapshot from memory with key: $storageKey',
    );
  } else {
    debugPrint('[Checkpoint] Snapshot not found in memory: $storageKey');
  }
  return snapshot;
}