startVerificationFlow method
Future<void>
startVerificationFlow({
- required BuildContext context,
- required VerificationType verificationType,
- File? documentFile,
- dynamic onVerificationComplete()?,
- dynamic onError()?,
Start the verification flow with app-controlled verification type The app decides whether to show complete verification or face-only verification
Implementation
Future<void> startVerificationFlow({
required BuildContext context,
required VerificationType verificationType,
File? documentFile, // Required when verificationType is facematch
Function(VerificationResponse)? onVerificationComplete,
Function(String)? onError,
}) async {
// Validate that documentFile is provided when verification type is facematch
if (verificationType == VerificationType.facematch && documentFile == null) {
throw ArgumentError('documentFile is required when verificationType is facematch');
}
// Bearer token must be provided via initialize() once by the host app
// Check for pending manual verification
final pendingSession = await getPendingSession();
if (pendingSession != null) {
final shouldStartNew = await showPendingVerificationDialog(context);
if (shouldStartNew == null) {
// User dismissed dialog, don't proceed
return;
} else if (shouldStartNew == false) {
// User wants to check status, handle in main app
if (pendingSession['session_id'] != null) {
onVerificationComplete?.call(VerificationResponse(
status: 'check_pending_status',
sessionId: pendingSession['session_id'],
message: 'Check pending verification status',
));
}
return;
} else {
// User wants to start new verification, clear pending session
await clearPendingSession();
}
}
// Show the verification flow with the specified verification type
await Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SotaIdVerificationFlow(
verificationType: verificationType,
documentFile: documentFile,
plugin: this, // Pass this plugin instance that already has the token
onVerificationComplete: (response) async {
// Store session if manual verification is required
if (response.status == 'requires_manual_verification') {
await storePendingSession(response);
}
onVerificationComplete?.call(response);
},
onError: onError,
),
),
);
}