flutter_secure_storage
flutter_secure_storage copied to clipboard
Delete All Not working in Version 9.2.4 in iOS simulator 18.2
I'm encountering an issue with Flutter Secure Storage 9.2.4. When I use the deleteAll function, it doesn't delete any data and doesn't show any error messages. This was working perfectly in version 9.0.0.
I'm testing this on an iPhone 16 Plus simulator. iOS version 18.2. No issues were noticed on my real device iPhone 11 running iOS 18.1.1.
Has anyone else experienced this or have any suggestions on how to fix it?
This is my code
class SecureStorageService {
late FlutterSecureStorage storage;
SecureStorageService() {
storage = const FlutterSecureStorage();
}
Future<bool> _write(String key, String value) async {
try {
await storage.write(key: key, value: value);
return true;
} catch (e, st) {
LoggingHelper.error(
errorMessage: 'Error in writing $key', error: e, stackTrace: st);
return false;
}
}
Future<String?> _read(String key) async {
try {
return await storage.read(key: key);
} catch (e, st) {
LoggingHelper.error(
errorMessage: 'Error in reading $key', error: e, stackTrace: st);
return null;
}
}
// ignore: unused_element
Future<bool> _delete(String key) async {
try {
await storage.delete(key: key);
return true;
} catch (e, st) {
LoggingHelper.error(
errorMessage: 'Error in deleting $key', error: e, stackTrace: st);
return false;
}
}
Future<bool> deleteAll() async {
try {
await storage.deleteAll();
return true;
} catch (e, st) {
LoggingHelper.error(
errorMessage: 'Error in deleting all', error: e, stackTrace: st);
return false;
}
}
}
Hi, i have tried your code, but i can't reproduce the behavior. Do you have any aditional steps i can take in order to reproduce this?
I have tried it with the example app, pinning the version to 9.0.0 and then adding items, then pinning the version to 9.2.4 and delete all works just fine.
I changed the default iOS options somewhere in between and reverted back as below
storage = const FlutterSecureStorage(iOptions: IOSOptions(accessibility: KeychainAccessibility.first_unlock,synchronizable:true )
Going back to 9.0.0 fixes this issue.
So you saved some items in 9.0.0, then added storage = const FlutterSecureStorage(iOptions: IOSOptions(accessibility: KeychainAccessibility.first_unlock,synchronizable:true ) and upgraded to 9.2.4, and then deleteAll isn't working?
yes.
Same here on physical IOS device. I originally had:
secureStorage = const FlutterSecureStorage();
And I saved my access tokens to key "access_token"
Then I realized I needed to add iOptions for my app to work properly, So I changed the code to
final secureStorage = const FlutterSecureStorage(
iOptions: IOSOptions(
accessibility: KeychainAccessibility.first_unlock_this_device,
synchronizable: true
)
);
Now I can't delete the data stored with key "access_token" I tried both
await secureStorage.deleteAll();
await secureStorage.delete(key: "heyring_access_token");
I also tried re-initializing
secureStorage = const FlutterSecureStorage();
Then tried deleteAll() and delete(...), but still no luck!
I'm facing a similar issue.
I have two instances of FlutterSecureStorage:
secureStorage1 = const FlutterSecureStorage();
secureStorage2 = const FlutterSecureStorage(
iOptions: IOSOptions(
accessibility: KeychainAccessibility.first_unlock_this_device,
),
);
There are some keys that were written using secureStorage1, but they are not being deleted when I call secureStorage2.deleteAll(). If I write and delete keys using the same instance, or if I make the constructors identical, it works as expected. Is this expected behaviour?
We recently upgraded the package from v8.1.0 to v9.2.4, and that's when we started noticing this behaviour.
I'm thinking of writing a migration script to handle this, or downgrade the version as suggested in other similar issues in this repository. However, it would be best to know if we can expect a fix for this from the maintainer.
Update: Works fine after downgrading to v9.0.0
⚠️ This issue has been marked as stale because it has been open for 60 days with no activity.
If this issue is still relevant, please comment to keep it active. Otherwise, it will be closed in 60 days.
Any updates?
⚠️ This issue has been marked as stale because it has been open for 60 days with no activity.
If this issue is still relevant, please comment to keep it active. Otherwise, it will be closed in 60 days.
I got rid of this and other typical issues by switching to flutter_secure_storage and flutter_secure_storage_darwin develop branches. There are many pr fixes that not available on pub dev