completeOnboarding method

Future<bool> completeOnboarding()

Implementation

Future<bool> completeOnboarding() async {
  emit(state.copyWith(isLoading: true));

  try {
    final profile = _buildUserProfile();
    final preferences = _buildOnboardingPreferences();

    final result = await _saveDataUseCase(
      profile: profile,
      preferences: preferences,
    );

    return result.fold(
      (failure) {
        emit(state.copyWith(
          isLoading: false,
          error: failure.message,
        ));
        return false;
      },
      (_) {
        emit(state.copyWith(isLoading: false));
        return true;
      },
    );
  } catch (e) {
    emit(state.copyWith(
      isLoading: false,
      error: e.toString(),
    ));
    return false;
  }
}