passo_mobile_app/lib/bloc/profile/profile_bloc.dart

26 lines
857 B
Dart
Raw Normal View History

import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/profile/profileInfomation.dart';
import 'package:unit2/sevices/profile/profile_service.dart';
part 'profile_event.dart';
part 'profile_state.dart';
class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
ProfileBloc() : super(ProfileInitial()) {
2023-02-27 06:26:27 +00:00
ProfileInformation? globalProfileInformation;
on<LoadProfile>((event, emit) async {
try {
emit(ProfileLoading());
ProfileInformation? profileInformation =
await ProfileService.instance.getProfile(event.token, event.userID);
globalProfileInformation = profileInformation;
emit(ProfileLoaded(profileInformation: globalProfileInformation!));
} catch (e) {
emit(ProfileErrorState(mesage: e.toString()));
}
});
}
}