createVerificationSession method

Future<VerificationSession> createVerificationSession({
  1. required VerificationType verificationType,
  2. File? documentFile,
})

Create a new verification session

Implementation

Future<VerificationSession> createVerificationSession({
  required VerificationType verificationType,
  File? documentFile, // Required when verificationType is facematch
}) 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');
  }

  try {
    final sessionData = {
      'verification_type': verificationType.value,
      'created_at': DateTime.now().toIso8601String(),
    };

    final Map<String, dynamic> response = await _plugin.createVerificationSession(sessionData, documentFile: documentFile);
    return VerificationSession.fromJson(response);
  } catch (e) {
    throw Exception('Failed to create verification session: $e');
  }
}