Fehlerkorrekturen und Erweiterungen
This commit is contained in:
1 parent
3fd8b0f9d4
commit
777876bc8d
8 files changed
+70
-45
No files matched your search
+15
-16
@@ -16,19 +16,22 @@ import 'package:uuid/uuid.dart';
|
||||
import '../Tools/colored_safe_area.dart';
|
||||
|
||||
class Util {
|
||||
static Future<bool> preferencesContainsKey(String key) async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
static late SharedPreferences prefs;
|
||||
|
||||
static init() async {
|
||||
prefs = await SharedPreferences.getInstance();
|
||||
}
|
||||
|
||||
static bool preferencesContainsKey(String key) {
|
||||
return prefs.containsKey(key);
|
||||
}
|
||||
|
||||
static void preferencesSaveString(String key, String value) async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString(key, value);
|
||||
}
|
||||
|
||||
static Future<String?> preferencesGetString(String key, String? defaultValue) async {
|
||||
if (await preferencesContainsKey(key)) {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
static String? preferencesGetString(String key, String? defaultValue) {
|
||||
if (preferencesContainsKey(key)) {
|
||||
return prefs.getString(key);
|
||||
}
|
||||
|
||||
@@ -36,13 +39,11 @@ class Util {
|
||||
}
|
||||
|
||||
static void preferencesSaveInt(String key, int value) async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt(key, value);
|
||||
}
|
||||
|
||||
static Future<int?> preferencesGetInt(String key, int? defaultValue) async {
|
||||
if (await preferencesContainsKey(key)) {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
static int? preferencesGetInt(String key, int? defaultValue) {
|
||||
if (preferencesContainsKey(key)) {
|
||||
return prefs.getInt(key);
|
||||
}
|
||||
|
||||
@@ -50,21 +51,19 @@ class Util {
|
||||
}
|
||||
|
||||
static void preferencesSaveBool(String key, bool value) async {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool(key, value);
|
||||
}
|
||||
|
||||
static Future<bool> preferencesGetBool(String key, bool defaultValue) async {
|
||||
if (await preferencesContainsKey(key)) {
|
||||
var prefs = await SharedPreferences.getInstance();
|
||||
static bool preferencesGetBool(String key, bool defaultValue) {
|
||||
if (preferencesContainsKey(key)) {
|
||||
return prefs.getBool(key) as bool;
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
static Future<String> getAppUuid() async {
|
||||
var currentUuid = await preferencesGetString('uuid', null);
|
||||
static String getAppUuid() {
|
||||
var currentUuid = preferencesGetString('uuid', null);
|
||||
|
||||
if (currentUuid == null) {
|
||||
currentUuid ??= const Uuid().v4();
|
||||
|
||||
Reference in new issue
Block a user