木鱼配置存储
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
const String kGuessSpKey = 'guess-config';
|
||||
const String kMuYUSpKey = 'muyu-config';
|
||||
|
||||
class SpStorage {
|
||||
SpStorage._();
|
||||
@@ -22,18 +23,37 @@ class SpStorage {
|
||||
}
|
||||
|
||||
Future<bool> saveGuessConfig({
|
||||
bool? guessing,
|
||||
int? value,
|
||||
required bool guessing,
|
||||
required int value,
|
||||
}) async {
|
||||
await initSpWhenNull();
|
||||
String content = json.encode({'guessing': guessing, 'value': value});
|
||||
return _sp!.setString(kGuessSpKey, content);
|
||||
}
|
||||
|
||||
Future<Map<String,dynamic>> readGuessConfig() async {
|
||||
Future<Map<String, dynamic>> readGuessConfig() async {
|
||||
await initSpWhenNull();
|
||||
String content = _sp!.getString(kGuessSpKey)??"{}";
|
||||
String content = _sp!.getString(kGuessSpKey) ?? "{}";
|
||||
return json.decode(content);
|
||||
}
|
||||
|
||||
Future<bool> saveMuYUConfig({
|
||||
required int counter,
|
||||
required int activeImageIndex,
|
||||
required int activeAudioIndex,
|
||||
}) async {
|
||||
await initSpWhenNull();
|
||||
String content = json.encode({
|
||||
'counter': counter,
|
||||
'activeImageIndex': activeImageIndex,
|
||||
'activeAudioIndex': activeAudioIndex,
|
||||
});
|
||||
return _sp!.setString(kMuYUSpKey, content);
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> readMuYUConfig() async {
|
||||
await initSpWhenNull();
|
||||
String content = _sp!.getString(kMuYUSpKey) ?? "{}";
|
||||
return json.decode(content);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user