Frontend first draft
This commit is contained in:
25
frontend/pshared/lib/service/secure_storage.dart
Normal file
25
frontend/pshared/lib/service/secure_storage.dart
Normal file
@@ -0,0 +1,25 @@
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class SecureStorageService {
|
||||
static Future<String?> get(String key) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
return prefs.getString(key);
|
||||
}
|
||||
|
||||
static Future<void> _setImp(SharedPreferences prefs, String key, String value) async {
|
||||
await prefs.setString(key, value);
|
||||
}
|
||||
|
||||
static Future<void> set(String key, String? value) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
if (value == null) {
|
||||
return delete(key);
|
||||
}
|
||||
return _setImp(prefs, key, value);
|
||||
}
|
||||
|
||||
static Future<void> delete(String key) async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.remove(key);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user