Fix local gen

This commit is contained in:
dane madsen
2023-11-30 18:57:53 +10:00
parent c19ff8119e
commit 23e2faf225
2 changed files with 12 additions and 2 deletions

View File

@@ -23,7 +23,12 @@ class Character extends ChangeNotifier {
Character() {
_initProfile().then((value) => resetAll());
SharedPreferences.getInstance().then((prefs) {
fromMap(json.decode(prefs.getString("last_character") ?? "{}"));
Map<String, dynamic> lastCharacter = json.decode(prefs.getString("last_character") ?? "{}");
if (lastCharacter.isNotEmpty) {
fromMap(lastCharacter);
} else {
resetAll();
}
});
}

View File

@@ -16,7 +16,12 @@ class Model extends ChangeNotifier {
Model() {
SharedPreferences.getInstance().then((prefs) {
fromMap(json.decode(prefs.getString("last_model") ?? "{}"));
Map<String, dynamic> lastModel= json.decode(prefs.getString("last_model") ?? "{}");
if (lastModel.isNotEmpty) {
fromMap(lastModel);
} else {
resetAll();
}
});
}