mogol / flutter_secure_storage

A Flutter plugin to store data in secure storage
https://pub.dartlang.org/packages/flutter_secure_storage
BSD 3-Clause "New" or "Revised" License
1.12k stars 367 forks source link

Reading a specific key or using read all returns a null from the store #744

Closed cmcgill1988 closed 3 months ago

cmcgill1988 commented 3 months ago

Background info: Recently I introduced firebase remote config to my application, which seems to have triggered an additional read of the stored encryption key at runtime. This read works correctly but subsequent reads afterwards return a null from the store as per the steps below.

I am using flutter_secure_storage to save a base64 encryption key which I read in order to decrypt a secure hive box. Any help with this would be really appreciated, otherwise I'm going to have to move away to use something like sqflite instead.

Repro steps:

  1. Save a key to the store
  2. Read key from store, it returns correctly
  3. Make two other reads in under 5 seconds which also come back correctly.
  4. Make a final read about 10 seconds after the last one
  5. readAll returns an empty map and read on the specific key returns null

Other information:

cmcgill1988 commented 3 months ago

Apologies, we had a race condition and some bad logic that was nuking the store on repaints under certain circumstances.