25 lines
759 B
Dart
25 lines
759 B
Dart
|
import 'package:bloc/bloc.dart';
|
||
|
import 'package:equatable/equatable.dart';
|
||
|
import 'package:unit2/sevices/profile/family_services.dart';
|
||
|
|
||
|
import '../../../model/profile/family_backround.dart';
|
||
|
|
||
|
part 'family_event.dart';
|
||
|
part 'family_state.dart';
|
||
|
|
||
|
class FamilyBloc extends Bloc<FamilyEvent, FamilyState> {
|
||
|
FamilyBloc() : super(FamilyInitial()) {
|
||
|
List<FamilyBackground> families = [];
|
||
|
on<GetFamilies>((event, emit) async{
|
||
|
emit(FamilyLoadingState());
|
||
|
try{
|
||
|
List<FamilyBackground> family = await FamilyService.instance.getFamilies(event.profileId, event.token);
|
||
|
families = family;
|
||
|
emit(FamilyLoaded(families: families));
|
||
|
}catch(e){
|
||
|
emit(FamilyErrorState(message: e.toString()));
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|