loadProfile method

Future<void> loadProfile()

Loads the user profile from storage

Implementation

Future<void> loadProfile() async {
  emit(state.copyWith(isLoading: true, error: null));

  final result = await getUserProfile();

  result.fold(
    (failure) => emit(state.copyWith(
      isLoading: false,
      error: failure.message,
    )),
    (profile) => emit(state.copyWith(
      profile: profile,
      isLoading: false,
      error: null,
    )),
  );
}