passo_mobile_app/lib/bloc/passo/municipality/municipality_bloc.dart

22 lines
684 B
Dart
Raw Permalink Normal View History

2023-09-01 03:22:48 +00:00
import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/city.dart';
import 'package:unit2/sevices/passo/municipality.dart';
part 'municipality_event.dart';
part 'municipality_state.dart';
class MunicipalityBloc extends Bloc<MunicipalityEvent, MunicipalityState> {
MunicipalityBloc() : super(MunicipalityInitial()) {
on<LoadMunicipality>((event, emit) async {
emit(MunicipalityLoading());
try {
final municipality = await MunicipalityServices.instance.fetch();
emit(MunicipalityLoaded(municipality));
} catch (e) {
emit(MunicipalityErrorState(e.toString()));
}
});
}
}