flutter_secure_storage
flutter_secure_storage copied to clipboard
Not working in windows web
Version:flutter_secure_storage: ^5.0.2
Enviroment: Windows web
When I call stoge.read jsonEncoded data ; raise "Uncaught (in promise) Error: OperationError”
Do you mean windows or web? Or do you mean web on windows development?
Also, make sure to post more details about the error your having...
+1 using web.
I have the following code:
class SharedPref {
static FlutterSecureStorage? _prefs;
static Map<String, String>? values;
static Future<void> load() async {
if (_prefs == null) {
_prefs = FlutterSecureStorage();
try {
values = await _prefs!.readAll();
} catch (e, s) {
log('SharedPref.load() error: $e, $s');
values = {};
}
}
}
static String? get(String key) {
return values![key];
}
static set(String key, String value) {
values![key] = value;
_prefs!.write(key: key, value: value);
}
}
I'm calling await SharedPref.load(); in my main.dart
I simply get an error saying:
[log] SharedPref.load() error: OperationError,
No stacktrace (not sure why), Here's my flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.5, on Ubuntu 22.04 LTS 5.15.0-43-generic, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2021.2)
[✓] Android Studio
[✓] IntelliJ IDEA Ultimate Edition (version 2022.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2022.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
Any suggestion on why this happens would be really helpful, thanks!
nvm, adding synchronized's Lock around writes solved it for me.
https://github.com/mogol/flutter_secure_storage/issues/381#issuecomment-1214431030