mirror of
https://github.com/ZhuJHua/moodiary.git
synced 2026-04-05 16:39:01 +08:00
feat: add secure storage to store user key
This commit is contained in:
21
lib/presentation/secure_storage.dart
Normal file
21
lib/presentation/secure_storage.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
class SecureStorageUtil {
|
||||
static const _storage = FlutterSecureStorage(
|
||||
aOptions: AndroidOptions(
|
||||
encryptedSharedPreferences: true,
|
||||
),
|
||||
);
|
||||
|
||||
static Future<void> setValue(String key, dynamic value) async {
|
||||
await _storage.write(key: key, value: value);
|
||||
}
|
||||
|
||||
static Future<String?> getValue(String key) async {
|
||||
return await _storage.read(key: key);
|
||||
}
|
||||
|
||||
static Future<void> remove(String key) async {
|
||||
await _storage.delete(key: key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user