handlePrimaryCurrencyCodeChangedEvent method

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

Handles the primaryCurrencyCodeChanged event by persisting the new primary currency code and updating the state.

The payload parameter contains the new primary currency code.

Implementation

Stream<FastAppSettingsBlocState> handlePrimaryCurrencyCodeChangedEvent(
  FastAppSettingsBlocEventPayload? payload,
) async* {
  if (payload?.primaryCurrencyCode != null) {
    final primaryCurrencyCode = payload?.primaryCurrencyCode;
    await _persistPrimaryCurrencyCode(primaryCurrencyCode);

    _logAnalyticsEvent('primary_currency_code', primaryCurrencyCode);

    yield currentState.copyWith(
      primaryCurrencyCode: _persistedSettings!.primaryCurrencyCode,
    );
  }
}