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

part 'land_classification_event.dart';
part 'land_classification_state.dart';

class LandClassificationBloc
    extends Bloc<LandClassificationEvent, LandClassificationState> {
  LandClassificationBloc() : super(LandClassificationLoading()) {
    on<LoadLandClassification>((event, emit) async {
      emit(LandClassificationLoading());
      try {
        final classs = await LandClassificationService.instance.fetch();
        emit(LandClassificationLoaded(classs));
      } catch (e) {
        emit(LandClassificationErrorState(e.toString()));
      }
    });
  }
}
