handleInitializedEvent method

Handle the FastAppSettingsBlocEventType.initialized event. This event is used to end the initialization process. It will set the bloc as initialized and dispatch a new state. The new state will contain the settings retrieved from the data provider.

Implementation

Stream<FastAppSettingsBlocState> handleInitializedEvent(
  FastAppSettingsBlocEventPayload? payload,
) async* {
  if (isInitializing) {
    _logger.debug('Initialized');
    isInitialized = true;

    yield currentState.copyWith(
      saveEntry: payload?.saveEntry ?? kFastAppSettingsSaveEntry,
      secondaryCurrencyCode: payload?.secondaryCurrencyCode,
      primaryCurrencyCode: payload?.primaryCurrencyCode,
      countryCode: () => payload?.countryCode,
      languageCode: payload?.languageCode,
      theme: payload?.theme,
      isInitializing: false,
      isInitialized: true,
    );
  }
}