handleThemeChangedEvent method

Stream<FastAppSettingsBlocState> handleThemeChangedEvent(
  1. FastAppSettingsBlocEventPayload? payload
)

Handle the FastAppSettingsBlocEventType.themeChanged event. This event is used to change the app theme. It will persist the theme in the data provider and dispatch a new state. The new state will contain the new theme.

Implementation

Stream<FastAppSettingsBlocState> handleThemeChangedEvent(
  FastAppSettingsBlocEventPayload? payload,
) async* {
  if (payload?.theme != null) {
    final theme = payload?.theme;
    await _persistTheme(theme);

    _logAnalyticsEvent('theme', theme);

    yield currentState.copyWith(theme: _persistedSettings!.theme);
  }
}