switchThemeMode static method

void switchThemeMode(
  1. BuildContext context
)

Implementation

static void switchThemeMode(BuildContext context) {
  var state = June.getState(ThemeModeChangerVM());
  switch (MaterialAppParams.themeMode) {
    case ThemeMode.light:
      MaterialAppParams.themeMode = ThemeMode.dark;
      break;
    case ThemeMode.dark:
      var brightness = MediaQuery.of(context).platformBrightness;
      MaterialAppParams.themeMode = (brightness == Brightness.dark)
          ? ThemeMode.light
          : ThemeMode.system;
      break;
    case ThemeMode.system:
      var brightness = MediaQuery.of(context).platformBrightness;
      MaterialAppParams.themeMode =
      (brightness == Brightness.light) ? ThemeMode.dark : ThemeMode.light;
      break;
    case null:
      var brightness = MediaQuery.of(context).platformBrightness;
      MaterialAppParams.themeMode =
      (brightness == Brightness.light) ? ThemeMode.dark : ThemeMode.light;
      break;
  }
  state.setState();
}