clear method

  1. @override
Future<void> clear()
override

Clears all snapshots from storage.

Returns: A Future that completes when all snapshots are cleared.

Implementation

@override
Future<void> clear() async {
  try {
    final prefs = await _prefs;
    final allKeys = prefs.getKeys();
    final snapshotKeys = allKeys.where((key) => key.startsWith(keyPrefix));

    for (final key in snapshotKeys) {
      await prefs.remove(key);
    }

    debugPrint('[Checkpoint] Cleared all snapshots from SharedPreferences');
  } catch (e) {
    debugPrint('[Checkpoint] Error clearing snapshots: $e');
  }
}