From 28e46d1806a978ea27ab6b4cb80d841e17cf47ee Mon Sep 17 00:00:00 2001 From: "k.mannweiler" <2012491@stud.hs-mannheim.de> Date: Mon, 27 Feb 2023 11:19:56 +0100 Subject: [PATCH] Settingsfields nullable --- lib/models/settings.dart | 14 +++++++------- lib/providers/settings_provider.dart | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/models/settings.dart b/lib/models/settings.dart index 0e7cf30..7dea33f 100644 --- a/lib/models/settings.dart +++ b/lib/models/settings.dart @@ -1,10 +1,10 @@ import 'package:smoke_cess_app/services/json_service.dart'; class Settings { - final int group; + final int? group; final List? relapseCategories; - final QueryConfig moodQuery; - final QueryConfig sleepQuery; + final QueryConfig? moodQuery; + final QueryConfig? sleepQuery; final TimeConfig? chessTime; Settings(this.group, this.relapseCategories, this.moodQuery, this.sleepQuery, @@ -21,8 +21,8 @@ class Settings { } class QueryConfig { - final int hours; - final int minutes; + final int? hours; + final int? minutes; final List? days; QueryConfig(this.hours, this.minutes, this.days); @@ -34,8 +34,8 @@ class QueryConfig { } class TimeConfig { - final int hours; - final int minutes; + final int? hours; + final int? minutes; TimeConfig(this.hours, this.minutes); diff --git a/lib/providers/settings_provider.dart b/lib/providers/settings_provider.dart index d7a2e0f..5283808 100644 --- a/lib/providers/settings_provider.dart +++ b/lib/providers/settings_provider.dart @@ -27,12 +27,12 @@ class SettingsProvider extends ChangeNotifier { int? chessMinutes = await getChessMinutes(); _settings = Settings( - group ?? 0, + group, relapseCategories, - QueryConfig(moodHours ?? 0, moodMinutes ?? 0, moodDays), - QueryConfig(sleepHours ?? 0, sleepMinutes ?? 0, sleepDays), - TimeConfig(chessHours ?? 0, chessMinutes ?? 0)); - _initialized = group != 0 ? true : false; + QueryConfig(moodHours, moodMinutes, moodDays), + QueryConfig(sleepHours, sleepMinutes, sleepDays), + TimeConfig(chessHours, chessMinutes)); + _initialized = group != null ? true : false; notifyListeners(); } }