22 lines
636 B
Dart
22 lines
636 B
Dart
|
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()));
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|