import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/passo/type_of_location.dart';
import 'package:unit2/sevices/passo/land/type_of_location.dart';

part 'type_of_location_event.dart';
part 'type_of_location_state.dart';

class TypeOfLocationBloc
    extends Bloc<TypeOfLocationEvent, TypeOfLocationState> {
  TypeOfLocationBloc() : super(TypeOfLocationInitial()) {
    on<LoadTypeOfLocation>((event, emit) async {
      emit(TypeOfLocationLoading());
      try {
        final locType = await TypeOfLocationServices.instance.fetch();
        emit(TypeOfLocationLoaded(locType));
      } catch (e) {
        emit(TypeOfLocationErrorState(e.toString()));
      }
    });
  }
}
