flutter_secure_storage
flutter_secure_storage copied to clipboard
Write on Mac doesn't overwrite previous value; Delete works fine;
I am experiencing this issue only on macOS. I suspect it's something related to Keychain, but I don't yet have enough experience with the lib internals to trace exactly what's going on.
In some cases when I write new value to a key, the new value doesn't end up in: key. It's like if the write to keychain has failed.
However when I delete the: key it gets deleted as expected.
It doesn't make difference if I try to read new value immediately after write or if I wait longer while or even restart app.
final secureStorage = FlutterSecureStorage();
final write = await secureStorage.write(key: "key", value: "newValue");
final value = await secureStorage.read(key: "key"); // Still returns old value !
final delete = await secureStorage.delete(key: "key");
final value = await secureStorage.read(key: "key"); // Key successfully deleted
I use latest: flutter_secure_storage 8.0.0 and Flutter:
[✓] Flutter (Channel stable, 3.10.5, on macOS 13.4 22F66 darwin-arm64, locale en-PL)
• Flutter version 3.10.5 on channel stable at /Users/tomek/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 796c8ef792 (12 days ago), 2023-06-13 15:51:02 -0700
• Engine revision 45f6e00911
• Dart version 3.0.5
• DevTools version 2.23.1
This issue doesn't seem to be present on Linux, Windows, iOS, Android and Web.
==
I've also noticed strange inconsistency between key versions depending if I run the "Debug" version of the app from the Android Studio or if I start the "Release" version from the compiled .DMG package.
Once I start release version of the app, I get this prompt
and the if I read the
key I get the: newValue.
After closing the app and starting the Debug version from the Android Studio:
I still get the:
oldValue, despite the fact the the: newValue was written from the Debug version.
I had the same problem
Same, we have to delete it before writing the data again.
@SebAubin thanks for the workaround. I have the same issue.
That's the big issue I guess. I also face it. Please, fix it or at least make a note in documentation that on Mac key should first be deleted before setting a new value.
Experiencing the same issue on Mac too.
Same problem here. Setting moption with synchronizable does work either (I gave it a try while not knowing what its intended function is.
I also have to delete before trying to update
macOS Sonoma Flutter (Channel stable, 3.16.4, on macOS 14.1.2 23B92 darwin-arm64, locale en-US)
Spent a long time banging my head on issues with GQL refreshToken today before realizing that the new token was never written to secureStorage 😓 . Manually deleting the old token first before writing worked.
I replied before that I had this issue, but on the current version (9.2.2) I can no longer replicate the issue. There was a recent update (May 16th 2024) that added some code from the iOS implementation, so maybe that helped.
https://github.com/mogol/flutter_secure_storage/commit/76299dd150984ae2194dbb40c7d18741d9b23722
I am closing all older issues. If this issue still exists in the latest version, please let me know.