Settingsfields nullable

main
Kai Mannweiler 2023-02-27 11:19:56 +01:00
parent b1c6288b2b
commit 28e46d1806
2 changed files with 12 additions and 12 deletions

View File

@ -1,10 +1,10 @@
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;
final TimeConfig? chessTime; final TimeConfig? chessTime;
Settings(this.group, this.relapseCategories, this.moodQuery, this.sleepQuery, Settings(this.group, this.relapseCategories, this.moodQuery, this.sleepQuery,
@ -21,8 +21,8 @@ class Settings {
} }
class QueryConfig { class QueryConfig {
final int hours; final int? hours;
final int minutes; final int? minutes;
final List<String>? days; final List<String>? days;
QueryConfig(this.hours, this.minutes, this.days); QueryConfig(this.hours, this.minutes, this.days);
@ -34,8 +34,8 @@ class QueryConfig {
} }
class TimeConfig { class TimeConfig {
final int hours; final int? hours;
final int minutes; final int? minutes;
TimeConfig(this.hours, this.minutes); TimeConfig(this.hours, this.minutes);

View File

@ -27,12 +27,12 @@ class SettingsProvider extends ChangeNotifier {
int? chessMinutes = await getChessMinutes(); int? chessMinutes = await getChessMinutes();
_settings = Settings( _settings = Settings(
group ?? 0, group,
relapseCategories, relapseCategories,
QueryConfig(moodHours ?? 0, moodMinutes ?? 0, moodDays), QueryConfig(moodHours, moodMinutes, moodDays),
QueryConfig(sleepHours ?? 0, sleepMinutes ?? 0, sleepDays), QueryConfig(sleepHours, sleepMinutes, sleepDays),
TimeConfig(chessHours ?? 0, chessMinutes ?? 0)); TimeConfig(chessHours, chessMinutes));
_initialized = group != 0 ? true : false; _initialized = group != null ? true : false;
notifyListeners(); notifyListeners();
} }
} }