setTheme static method

void setTheme(
  1. String name
)

Switches to the theme with the specified name.

If a storage adapter was provided during initialization, the theme preference is automatically saved.

Does nothing if the theme doesn't exist. Use hasTheme to check first.

Implementation

static void setTheme(String name) async {
  final theme = _instance._themes[name];

  if (theme == null) return;

  _instance.themeNotifier.value = theme;
  _instance._currentThemeName = name;

  if (_instance._storageAdapter != null) {
    await _instance._storageAdapter!.saveTheme(name);
  }
}