add sp and support save the width and height

This commit is contained in:
Siyi Guo committed 2023-04-13 15:21:40 +08:00
1 parent 1c53032b3f
commit 595ee6fd6a
9 files changed
+187 -10

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import 'package:shared_preferences/shared_preferences.dart';
class SP {
static late SharedPreferences prefs;
static Future<void> init() async {
prefs = await SharedPreferences.getInstance();
}
static double getDouble(String key, [double def = 0]) {
return prefs.getDouble(key) ?? def;
}
static Future<bool> setDouble(String key, double value) {
return prefs.setDouble(key, value);
}
}