updateThemeMode method
Updates the theme mode of the application.
Implementation
Future<void> updateThemeMode(
BuildContext context,
FastAppSettingsBlocState settingsState,
) async {
final themeBloc = FastThemeBloc.instance;
themeBloc.addEvent(FastThemeBlocEvent.init(settingsState.themeMode));
final themeState = await RaceStream([
themeBloc.onError,
themeBloc.onData.where(
(state) {
return state.themeMode == settingsState.themeMode &&
state.isInitialized;
},
),
]).first;
if (themeState is! FastThemeBlocState) {
_logger.error('Failed to update theme mode: $themeState');
throw themeState;
}
}