passo_mobile_app/lib/bloc/passo/barangay/barangay_bloc.dart

22 lines
636 B
Dart
Raw 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/barangay.dart';
import 'package:unit2/sevices/passo/barangay.dart';
part 'barangay_event.dart';
part 'barangay_state.dart';
class BarangayBloc extends Bloc<BarangayEvent, BarangayState> {
BarangayBloc() : super(BarangayInitial()) {
on<LoadBarangay>((event, emit) async {
emit(BarangayLoading());
try {
final barangay = await BarangayServices.instance.fetch(event.id);
emit(BarangayLoaded(barangay));
} catch (e) {
emit(BarangayErrorState(e.toString()));
}
});
}
}