flutter_secure_storage
flutter_secure_storage copied to clipboard
Windows Error
After a recent upgrade of flutter_securre_storage, I keep getting the following error under Windows...
Launching lib\main.dart on Windows in debug mode...
√ Built build\windows\runner\Debug\sandis_list.exe.
Connecting to VM Service at ws://127.0.0.1:49857/9uCr3Nyrbfs=/ws
flutter: Failed to decrypt data: Error 0x00000000: Failure on CryptUnprotectData() Delete corrupt file: c:\users\shane\appdata\roaming\tanstaaflsoftware\sandis_list\flutter_secure_storage.dat
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Error 0x00000000: Failure on CryptUnprotectData()
#0 DpapiJsonFileMapStorage.load.
I haven't changed this part of my code in almost 6 months!
Any idea on how to fix or what could have changed?
All the best,
Aggie85
This error is caused by multiple writes to the storage.
Сode example to reproduce the error (need to quickly scroll the list):
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
late final FlutterSecureStorage storage;
void main() {
storage = const FlutterSecureStorage();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
var controller = ScrollController();
controller.addListener(
() => storage.write(key: "key", value: "${controller.offset}"),
);
return MaterialApp(
title: 'Scroll quickly to see the bug.',
home: Scaffold(
body: ListView(
controller: controller,
children: [for (int i = 0; i < 100; i++) Text("$i")],
),
),
);
}
}
This error is caused by multiple writes to the storage.
Сode example to reproduce the error (need to quickly scroll the list):
import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; late final FlutterSecureStorage storage; void main() { storage = const FlutterSecureStorage(); runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { var controller = ScrollController(); controller.addListener( () => storage.write(key: "key", value: "${controller.offset}"), ); return MaterialApp( title: 'Scroll quickly to see the bug.', home: Scaffold( body: ListView( controller: controller, children: [for (int i = 0; i < 100; i++) Text("$i")], ), ), ); } }
@mogol plz fix asap
I am closing all older issues. If this issue still exists in the latest version, please let me know.