26 lines
801 B
Dart
26 lines
801 B
Dart
|
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());
|
||
|
}
|
||
|
|
||
|
});
|
||
|
}
|
||
|
}
|