return null if settings cant be correctly loaded
parent
21470da038
commit
9c4a5e0fbb
|
@ -1,7 +1,7 @@
|
||||||
import 'package:smoke_cess_app/services/json_service.dart';
|
import 'package:smoke_cess_app/services/json_service.dart';
|
||||||
|
|
||||||
class Settings {
|
class Settings {
|
||||||
final int? group;
|
final int group;
|
||||||
final List<String>? relapseCategories;
|
final List<String>? relapseCategories;
|
||||||
final QueryConfig? moodQuery;
|
final QueryConfig? moodQuery;
|
||||||
final QueryConfig? sleepQuery;
|
final QueryConfig? sleepQuery;
|
||||||
|
|
|
@ -66,7 +66,7 @@ void saveSettings(Settings settings) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Settings> loadSettings() async {
|
Future<Settings?> loadSettings() async {
|
||||||
int? group = await getGroup();
|
int? group = await getGroup();
|
||||||
List<String>? relapseCategories = await getRelapseCategories();
|
List<String>? relapseCategories = await getRelapseCategories();
|
||||||
int? moodHours = await getMoodQueryHours();
|
int? moodHours = await getMoodQueryHours();
|
||||||
|
@ -78,10 +78,13 @@ Future<Settings> loadSettings() async {
|
||||||
int? chessHours = await getChessHours();
|
int? chessHours = await getChessHours();
|
||||||
int? chessMinutes = await getChessMinutes();
|
int? chessMinutes = await getChessMinutes();
|
||||||
|
|
||||||
return Settings(
|
if (group != null) {
|
||||||
group,
|
return Settings(
|
||||||
relapseCategories,
|
group,
|
||||||
QueryConfig(moodHours, moodMinutes, moodDays),
|
relapseCategories,
|
||||||
QueryConfig(sleepHours, sleepMinutes, sleepDays),
|
QueryConfig(moodHours, moodMinutes, moodDays),
|
||||||
TimeConfig(chessHours, chessMinutes));
|
QueryConfig(sleepHours, sleepMinutes, sleepDays),
|
||||||
|
TimeConfig(chessHours, chessMinutes));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue