Add ensemble.storage.clear() method#2213
Merged
Merged
Conversation
Adds a clear() method to ensemble.storage that removes all normal storage values while preserving encrypted storage (enc_ prefixed keys), secure storage, keychain values, and system storage. Changes: - PublicStorage mixin: add getKeys() and clearPublicStorage() - EnsembleStorage: add clear() method with UI binding dispatch - Register 'clear' in EnsembleStorage.methods() - Add unit tests for the clear logic Fixes #2187 Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a
clear()method toensemble.storagethat removes all normal storage values at once, enabling developers to reset persisted local storage data when needed.Related Issue
Fixes #2187
Type of Change
What Has Changed
storage_manager.dart(PublicStoragemixin): AddedgetKeys()to retrieve all public storage keys, andclearPublicStorage()to remove all non-encrypted entries from the publicGetStoragecontainer.data_context.dart(EnsembleStorage): Addedclear()method that clears all normal storage keys and dispatchesStorageBindingSourcechange events for each removed key so UI bindings refresh. Registered'clear'in themethods()map.test/storage_manager_test.dart: Added 5 unit tests covering the clear logic — filtering, empty storage, mixed keys, encrypted key preservation, and post-clear usability.API
Behavior
ensemble.storageenc_prefixed keys in the sameGetStoragebox)FlutterSecureStorage), system storage (GetStorage('system')), keychain values, secrets, or environment variablesStorageBindingSourcechange events for each cleared key so UI expressions/bindings update correctlyGetStoragewhich is cross-platform)get,set,deletemethods continue to work after clearingHow to Test
melos bootstrapfrom the repo rootflutter test test/storage_manager_test.dartinmodules/ensemble/— 5 tests should passflutter testinmodules/ensemble/— all 88 tests should passensemble.storage.clear()after setting some values — all values should be removed and any UI bindings should updateChecklist
flutter analyzeand addressed any new warningsflutter testand all tests pass