2023-02-01 08:03:05 +00:00
|
|
|
import 'package:bloc/bloc.dart';
|
|
|
|
import 'package:equatable/equatable.dart';
|
|
|
|
import 'package:unit2/model/profile/basic_info.dart';
|
|
|
|
import 'package:unit2/model/profile/basic_information/primary-information.dart';
|
|
|
|
import 'package:unit2/model/profile/profileInfomation.dart';
|
|
|
|
import 'package:unit2/sevices/profile/profile_service.dart';
|
|
|
|
|
|
|
|
import '../../model/profile/basic_info.dart';
|
|
|
|
import '../../model/profile/basic_info.dart';
|
|
|
|
|
|
|
|
part 'profile_event.dart';
|
|
|
|
part 'profile_state.dart';
|
|
|
|
|
|
|
|
class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
|
|
|
ProfileBloc() : super(ProfileInitial()) {
|
|
|
|
ProfileInformation? _profileInformation;
|
|
|
|
on<LoadProfile>((event, emit) async {
|
2023-02-03 03:34:09 +00:00
|
|
|
// try {
|
2023-02-01 08:03:05 +00:00
|
|
|
emit(ProfileLoading());
|
|
|
|
ProfileInformation? profileInformation =
|
|
|
|
await ProfileService.instance.getProfile(event.token, event.userID);
|
|
|
|
_profileInformation = profileInformation;
|
|
|
|
emit(ProfileLoaded(
|
|
|
|
profileInformation: _profileInformation!));
|
2023-02-03 03:34:09 +00:00
|
|
|
// } catch (e) {
|
|
|
|
// emit(ProfileErrorState(mesage: e.toString()));
|
|
|
|
// }
|
2023-02-01 08:03:05 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|