setThemeMode method

Future<void> setThemeMode(
  1. ThemeMode themeMode
)

setThemeMode sets the theme mode based on the provided themeMode.

Implementation

Future<void> setThemeMode(ThemeMode themeMode) async {
  switch (themeMode) {
    case ThemeMode.dark:
      await _sharedPreferences.setBool(_isDarkKey, true);
      break;
    case ThemeMode.light:
      await _sharedPreferences.setBool(_isDarkKey, false);
      break;
    case ThemeMode.system:
      await _sharedPreferences.remove(_isDarkKey);
      break;
  }

  notifyListeners();
}