mapEventToState method

  1. @override
Stream<MatexCountryBlocState> mapEventToState(
  1. MatexCountryBlocEvent event
)
override

Maps incoming MatexCountryBlocEvent to corresponding MatexCountryBlocState. Processes events and updates states accordingly.

Implementation

@override
Stream<MatexCountryBlocState> mapEventToState(event) async* {
  final payload = event.payload;
  final type = event.type;

  if (type == MatexCountryBlocEventType.init) {
    yield* handleInitEvent(payload?.jsonData ?? jsonData);
  } else if (type == MatexCountryBlocEventType.initialized) {
    yield* handleInitializedEvent(payload?.countries);
  } else {
    assert(false, 'MatexCountryBloc is not initialized yet.');
  }
}