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';
|
||||
|
||||
class Settings {
|
||||
final int? group;
|
||||
final int group;
|
||||
final List<String>? relapseCategories;
|
||||
final QueryConfig? moodQuery;
|
||||
final QueryConfig? sleepQuery;
|
||||
|
|
|
@ -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,10 +78,13 @@ Future<Settings> loadSettings() async {
|
|||
int? chessHours = await getChessHours();
|
||||
int? chessMinutes = await getChessMinutes();
|
||||
|
||||
return Settings(
|
||||
group,
|
||||
relapseCategories,
|
||||
QueryConfig(moodHours, moodMinutes, moodDays),
|
||||
QueryConfig(sleepHours, sleepMinutes, sleepDays),
|
||||
TimeConfig(chessHours, chessMinutes));
|
||||
if (group != null) {
|
||||
return Settings(
|
||||
group,
|
||||
relapseCategories,
|
||||
QueryConfig(moodHours, moodMinutes, moodDays),
|
||||
QueryConfig(sleepHours, sleepMinutes, sleepDays),
|
||||
TimeConfig(chessHours, chessMinutes));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue