Skip to content

Add ensemble.storage.clear() method#2213

Merged
sharjeelyunus merged 1 commit into
mainfrom
cursor/storage-clear-913d
May 19, 2026
Merged

Add ensemble.storage.clear() method#2213
sharjeelyunus merged 1 commit into
mainfrom
cursor/storage-clear-913d

Conversation

@sharjeelyunus
Copy link
Copy Markdown
Member

Description

Adds a clear() method to ensemble.storage that removes all normal storage values at once, enabling developers to reset persisted local storage data when needed.

Related Issue

Fixes #2187

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

What Has Changed

  • storage_manager.dart (PublicStorage mixin): Added getKeys() to retrieve all public storage keys, and clearPublicStorage() to remove all non-encrypted entries from the public GetStorage container.
  • data_context.dart (EnsembleStorage): Added clear() method that clears all normal storage keys and dispatches StorageBindingSource change events for each removed key so UI bindings refresh. Registered 'clear' in the methods() 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

ensemble.storage.clear();

Behavior

  • Removes all values stored through ensemble.storage
  • Preserves encrypted storage (enc_ prefixed keys in the same GetStorage box)
  • Does not touch secure storage (FlutterSecureStorage), system storage (GetStorage('system')), keychain values, secrets, or environment variables
  • Dispatches StorageBindingSource change events for each cleared key so UI expressions/bindings update correctly
  • Works consistently across web, iOS, and Android (uses GetStorage which is cross-platform)
  • Existing get, set, delete methods continue to work after clearing

How to Test

  1. Run melos bootstrap from the repo root
  2. Run flutter test test/storage_manager_test.dart in modules/ensemble/ — 5 tests should pass
  3. Run flutter test in modules/ensemble/ — all 88 tests should pass
  4. In a running app, call ensemble.storage.clear() after setting some values — all values should be removed and any UI bindings should update

Checklist

  • I have run flutter analyze and addressed any new warnings
  • I have run flutter test and all tests pass
  • I have tested my changes on the relevant platform(s)
  • I have updated documentation if needed
  • My changes do not introduce new warnings or errors
Open in Web Open in Cursor 

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>
@sharjeelyunus sharjeelyunus marked this pull request as ready for review May 19, 2026 13:15
@sharjeelyunus sharjeelyunus merged commit 17e937d into main May 19, 2026
5 checks passed
@sharjeelyunus sharjeelyunus deleted the cursor/storage-clear-913d branch May 19, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

clear storage functionality

2 participants