Constant Dark Theme

This commit is contained in:
2023-12-30 14:43:16 +02:00
parent 9ab300b6b8
commit fedc5df0c7
4 changed files with 95 additions and 1 deletions

27
lib/storage_manager.dart Normal file
View File

@@ -0,0 +1,27 @@
import 'package:shared_preferences/shared_preferences.dart';
class StorageManager {
static void saveData(String key, dynamic value) async {
final prefs = await SharedPreferences.getInstance();
if (value is int) {
prefs.setInt(key, value);
} else if (value is String) {
prefs.setString(key, value);
} else if (value is bool) {
prefs.setBool(key, value);
} else {
throw("Invalid Type (Shared Preference Error)");
}
}
static Future<dynamic> readData(String key) async {
final prefs = await SharedPreferences.getInstance();
dynamic obj = prefs.get(key);
return obj;
}
static Future<bool> deleteData(String key) async {
final prefs = await SharedPreferences.getInstance();
return prefs.remove(key);
}
}