import 'package:flutter/material.dart'; import 'package:smoke_cess_app/services/settings_service.dart'; import '../models/settings.dart'; class SettingsProvider extends ChangeNotifier { Settings? _settings; bool _initialized = false; Settings? get settings => _settings; bool get initialized => _initialized; SettingsProvider() { initSettings(); } void initSettings() async { int? group = await getGroup(); List? relapseCategories = await getRelapseCategories(); int? moodHours = await getMoodQueryHours(); int? moodMinutes = await getMoodQueryMinutes(); List? moodDays = await getMoodQueryDaysCategories(); int? sleepHours = await getSleepQueryHours(); int? sleepMinutes = await getSleepQueryMinutes(); List? sleepDays = await getSleepQueryDaysCategories(); int? chessHours = await getChessHours(); int? chessMinutes = await getChessMinutes(); _settings = Settings( group ?? 0, relapseCategories, QueryConfig(moodHours ?? 0, moodMinutes ?? 0, moodDays), QueryConfig(sleepHours ?? 0, sleepMinutes ?? 0, sleepDays), TimeConfig(chessHours ?? 0, chessMinutes ?? 0)); _initialized = group != 0 ? true : false; notifyListeners(); } }