passo_mobile_app/lib/bloc/profile/education/education_bloc.dart

26 lines
982 B
Dart
Raw Normal View History

import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/profile/educational_background.dart';
import 'package:unit2/sevices/profile/education_services.dart';
part 'education_event.dart';
part 'education_state.dart';
class EducationBloc extends Bloc<EducationEvent, EducationState> {
List<EducationalBackground> educationalBackgrounds = [];
EducationBloc() : super(EducationInitial()) {
on<GetEducationalBackground>((event, emit) async {
emit(EducationalBackgroundLoadingState());
try {
List<EducationalBackground> educations = await EducationService.instace
.getEducationalBackground(event.profileId, event.token);
educationalBackgrounds = educations;
emit(EducationalBackgroundLoadedState(
educationalBackground: educationalBackgrounds));
} catch (e) {
emit(EducationalBackgroundErrorState(message: e.toString()));
}
});
}
}