flutter_secure_storage icon indicating copy to clipboard operation
flutter_secure_storage copied to clipboard

Weird issue where for iOS only

Open curtis2101 opened this issue 11 months ago • 7 comments

There is an issue where the top line of a storeAndOverwrite function is saved and able to be read when the app is running. But on restart of the app the top line that was written could not be found at all. This happens only on IOS and to fix this I Have added a future delay for now. So in this example without a delay the biometric preference would read while the app is running and its just been saved but on restart it would not show but all the other keys and values would be. Future storeAndOverwrite(SecureStorageContent storedContent) async { await Future.delayed(const Duration( milliseconds: 200)); //do not remove this line seems to be a ios issue where the top line is not stored await storage.write( key: Dummy.biometricPreference, value: storedContent.biometricPreference); await storage.write( key: Dummy.soundPreference, value: storedContent.soundPreference); await storage.write( key: Dummy.vibrationPreference, value: storedContent.vibrationPreference); await storage.write(key: LegacyConstants.email, value: storedContent.email); await storage.write( key: Dummy.password, value: storedContent.password); await storage.write( key: Dummy.accessToken, value: storedContent.accessToken); await getStoredContent(); }

curtis2101 avatar Sep 15 '23 12:09 curtis2101

I have updated with new IOS versions, after that I had got same issue, String type data is not get stored. but its working fine in android, even in IOS debug mode not working in release mode.

Any idea whats going wrong..!

harshitwe360 avatar Oct 04 '23 12:10 harshitwe360

I am having the same issue with 9.0.0. Took me forever to track down that this plugin was the problem. Issue only occurs in iOS release builds. Nowhere else.

MatthewJones517 avatar Oct 23 '23 20:10 MatthewJones517

After digging in a bit deeper, I found that this was caused by doing a read immediately after doing a write. We weren't fully awaiting the save, so only part of the value made it in to secure storage before we pulled it out.

I'm not saying that's everyone's problem, but it's something to check for those that stumble on this thread in the future.

MatthewJones517 avatar Oct 24 '23 15:10 MatthewJones517

so @MatthewJones517 , have you solve it ??

Kijacode avatar Oct 29 '23 13:10 Kijacode

Is the problem still relevant?

cheymos avatar Jan 18 '24 14:01 cheymos

any update on this?

aswinranjith-iouring avatar May 21 '24 07:05 aswinranjith-iouring

Version 9.2.1 fixed a race condition issue with read/write, which could be this issue. It would be great if someone can check if this version still has this issue.

juliansteenbakker avatar May 21 '24 09:05 juliansteenbakker

I am closing all older issues. If this issue still exists in the latest version, please let me know.

juliansteenbakker avatar Aug 13 '24 20:08 juliansteenbakker