feat:参照研听的基础工程

This commit is contained in:
jingyun
2026-06-18 15:02:28 +08:00
commit 364fc837b3
367 changed files with 16495 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import 'package:shared_preferences/shared_preferences.dart';
class StorageService {
StorageService._(this._prefs);
final SharedPreferences _prefs;
static StorageService? _instance;
static StorageService get to => _instance!;
static Future<StorageService> get instance async {
if (_instance != null) return _instance!;
final prefs = await SharedPreferences.getInstance();
_instance = StorageService._(prefs);
return _instance!;
}
bool getBool(String key, {bool def = false}) => _prefs.getBool(key) ?? def;
Future<void> setBool(String key, bool v) => _prefs.setBool(key, v);
String? getString(String key) => _prefs.getString(key);
Future<void> setString(String key, String v) => _prefs.setString(key, v);
}