passo_mobile_app/lib/bloc/profile/references/references_bloc.dart

26 lines
804 B
Dart
Raw Normal View History

import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/sevices/profile/references_services.dart';
import '../../../model/profile/references.dart';
part 'references_event.dart';
part 'references_state.dart';
class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
List<PersonalReference> references = [];
ReferencesBloc() : super(ReferencesInitial()) {
on<GetReferences>((event, emit) async{
emit(ReferencesLoadingState());
try{
List<PersonalReference> refs = await ReferencesServices.instace.getRefences(event.profileId, event.token);
references = refs;
emit(ReferencesLoadedState(references: references));
}catch(e){
ReferencesErrorState(message: e.toString());
}
});
}
}