return null if settings cant be correctly loaded

main
Kai Mannweiler 2023-02-27 11:39:42 +01:00
parent 21470da038
commit 9c4a5e0fbb
2 changed files with 11 additions and 8 deletions

View File

@ -1,7 +1,7 @@
import 'package:smoke_cess_app/services/json_service.dart';
class Settings {
final int? group;
final int group;
final List<String>? relapseCategories;
final QueryConfig? moodQuery;
final QueryConfig? sleepQuery;

View File

@ -66,7 +66,7 @@ void saveSettings(Settings settings) {
}
}
Future<Settings> loadSettings() async {
Future<Settings?> loadSettings() async {
int? group = await getGroup();
List<String>? relapseCategories = await getRelapseCategories();
int? moodHours = await getMoodQueryHours();
@ -78,6 +78,7 @@ Future<Settings> loadSettings() async {
int? chessHours = await getChessHours();
int? chessMinutes = await getChessMinutes();
if (group != null) {
return Settings(
group,
relapseCategories,
@ -85,3 +86,5 @@ Future<Settings> loadSettings() async {
QueryConfig(sleepHours, sleepMinutes, sleepDays),
TimeConfig(chessHours, chessMinutes));
}
return null;
}