handleInitEvent method

Stream<MatexCountryBlocState> handleInitEvent(
  1. String? jsonData
)

Processes the initialization event. It fetches country metadata and triggers the initialized event.

Implementation

Stream<MatexCountryBlocState> handleInitEvent(String? jsonData) async* {
  if (canInitialize) {
    isInitializing = true;
    yield MatexCountryBlocState(isInitializing: true);

    _countryProvider = MatexCountryDataProvider(jsonData: jsonData);
    final countries = await _countryProvider.list();

    addEvent(MatexCountryBlocEvent.initialized(countries));
  }
}