Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

31 righe
951 B

import 'package:flutter_secure_storage/flutter_secure_storage.dart';
class SecureStore {
SecureStore._();
static const _storage = FlutterSecureStorage(
aOptions: AndroidOptions(
encryptedSharedPreferences: true,
),
iOptions: IOSOptions(
accessibility: KeychainAccessibility.first_unlock,
),
);
// String
static Future<void> write(String key, String value) => _storage.write(key: key, value: value);
static Future<String?> read(String key) => _storage.read(key: key);
static Future<void> delete(String key) => _storage.delete(key: key);
static Future<void> deleteAll() => _storage.deleteAll();
// Bool
static Future<void> writeBool(String key, bool value) => write(key, value ? '1' : '0');
static Future<bool> readBool(String key, {bool defaultValue = false}) async {
final v = await read(key);
if (v == null) return defaultValue;
return v == '1' || v.toLowerCase() == 'true';
}
}