loadSettings method

Future<void> loadSettings()

Load the user's settings from the SettingsService. It may load from a local database or the internet. The controller only knows it can load the settings from the service.

Implementation

Future<void> loadSettings() async {
  _themeMode = _settingsService.themeMode();

  // _cardinalitySelection = await _settingsService.cardinalitySelection();
  _cardinalitySelection = CardinalitySelection(
      _sharedPreferences.getBool("cardinality.singularEnabled") ?? true,
      _sharedPreferences.getBool("cardinality.pluralEnabled") ?? true);

  Object? engineVar = _sharedPreferences.get('streakEngine');
  if (engineVar == null) {
    _streakEngine = StreakEngine();
  } else {
    if (engineVar is String) {
      Map<String, dynamic> engineMap = jsonDecode(engineVar);
      _streakEngine = StreakEngine.fromJson(engineMap);
    } else {
      if (kDebugMode) {
        print(engineVar.runtimeType.toString());
      }
    }
  }

  // Important! Inform listeners a change has occurred.
  notifyListeners();
}