switchTheme method

ArcaneThemeService switchTheme({
  1. ThemeMode? themeMode,
})

Switches the current theme between light and dark modes.

If the theme is currently light, it switches to dark, and vice versa. It also notifies listeners to update the UI accordingly.

Example:

ArcaneThemeService.I.switchTheme();
// or
ArcaneThemeService.I.switchTheme(themeMode: ThemeMode.dark);
// or
Arcane.theme.switchTheme(themeMode: ThemeMode.light);

Implementation

ArcaneThemeService switchTheme({ThemeMode? themeMode}) {
  _followingSystemTheme = false;

  if (themeMode != null) {
    _updateTheme(themeMode);
  } else {
    final ThemeMode effectiveMode = _effectiveThemeMode;
    _updateTheme(
      effectiveMode == ThemeMode.dark ? ThemeMode.light : ThemeMode.dark,
    );
  }

  return I;
}