completeAgeVerification method
Future<void>
completeAgeVerification(
)
Implementation
Future<void> completeAgeVerification() async {
final ageVerificationId = state.ageVerificationId;
if (ageVerificationId == null) {
debugPrint("β DART: No active age verification session");
state = state.copyWith(
step: AgeVerificationStep.error,
error: "No active age verification session"
);
return;
}
debugPrint("π DART: Completing age verification...");
state = state.copyWith(
step: AgeVerificationStep.processing,
isLoading: true
);
try {
final request = CompleteAgeVerificationRequest(ageVerificationId: ageVerificationId);
await ApiClient.shared.perform(request, sessionRequest: false);
debugPrint("β
DART: Age verification completed successfully");
state = state.copyWith(
step: AgeVerificationStep.completed,
isLoading: false
);
// Brief delay to show success, then dismiss
await Future.delayed(const Duration(seconds: 2));
state = state.copyWith(shouldDismiss: true);
onCompletion?.call();
} catch (error) {
debugPrint("β DART: Failed to complete age verification: $error");
state = state.copyWith(
step: AgeVerificationStep.error,
isLoading: false,
error: "Failed to complete age verification: ${error.toString()}",
);
}
}