22 lines
667 B
Dart
22 lines
667 B
Dart
|
import 'package:bloc/bloc.dart';
|
||
|
import 'package:equatable/equatable.dart';
|
||
|
import 'package:unit2/model/passo/bldg_loc.dart';
|
||
|
import 'package:unit2/sevices/passo/building/location_landref_services.dart';
|
||
|
|
||
|
part 'location_event.dart';
|
||
|
part 'location_state.dart';
|
||
|
|
||
|
class LocationBloc extends Bloc<LocationEvent, LocationState> {
|
||
|
LocationBloc() : super(LocationLoading()) {
|
||
|
on<LoadLocation>((event, emit) async {
|
||
|
emit(LocationLoading());
|
||
|
try {
|
||
|
final bldgloc = await LocationLandrefServices.instance.fetch(event.id);
|
||
|
emit(LocationLoaded(bldgloc));
|
||
|
} catch (e) {
|
||
|
emit(LocationErrorState(e.toString()));
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|