changeTheme static method
void
changeTheme({
- @Deprecated('No longer needed; the theme can be changed without a BuildContext.') BuildContext? context,
- required String themeKey,
Switches the whole app to the theme registered under themeKey and persists it.
The current page stays on screen; every widget reading the theme rebuilds with the new one.
Throws AppThemeException if themeKey is unknown or init has not completed.
Implementation
static void changeTheme({
@Deprecated('No longer needed; the theme can be changed without a BuildContext.') BuildContext? context,
required String themeKey,
}) {
final bloc = _requireBloc();
final theme = _findTheme(themeKey);
if (theme == null) {
throw AppThemeException('${ThemeExceptionConstants.notFoundKey} Key: "$themeKey".');
}
bloc.add(AppThemeEvent.changeTheme(theme));
}