Skip to content

Commit

Permalink
fix: incorrect detection of data migration status caused data to beco…
Browse files Browse the repository at this point in the history
…me invalid in some case
  • Loading branch information
w568w committed Nov 26, 2024
1 parent c7fdaf8 commit cf3d235
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/util/shared_preferences.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,14 @@ class XSharedPreferences {

// Proxy methods for [EncryptedSharedPreferences]

Future<bool> clear() => _preferences.clear();
Future<bool> clear() async {
bool success = await _preferences.clear();
if (success) {
// mark the data as migrated after clearing. Or the data written after clearing will be re-migrated.
await _instance!.setBool(KEY_MIGRATED, true);
}
return success;
}

Future<bool> remove(String key) => _preferences.remove(key);

Expand Down

0 comments on commit cf3d235

Please sign in to comment.