saketh
saketh

Reputation: 327

Flutter secure storage not storing once app is closed

My Flutter app not storing data once app is closed i had seen similar question in stackoverflow but it is not helpful for me here is my code

Storage.dart

final _storage = new FlutterSecureStorage();

Future<String> read(String key) async{
  String val = await _storage.read(key: key);
  return val;
}

Future<void> write({String key, String value}){
  _storage.write(key: key, value: value);
}

Future<void> delete(String key){
  _storage.delete(key: key);
}

Future<void> deleteAll(){
  _storage.deleteAll();
}

I am using this file where ever i want to access flutter secure storage it is working as expected until hot reload or exiting the app. Once if i do hot reload or if re-open the app i am not receiving data

Upvotes: 3

Views: 7007

Answers (2)

jackypan1989
jackypan1989

Reputation: 2866

https://github.com/mogol/flutter_secure_storage/issues/96

According to above link, FlutterSecureStorage does not support flutter-web yet.
Maybe you could try https://pub.dev/packages/crypted_preferences to get storage.

Upvotes: 0

Derek Fredrickson
Derek Fredrickson

Reputation: 752

Try making the write, delete, and deleteAll functions async with awaits. Example is right here:

https://pub.dev/packages/flutter_secure_storage

I'm not sure if that will fix your issue because I don't know when or how you're calling these functions, but it's worth a shot.

Upvotes: 1

Related Questions