videokyc_flutter 1.0.3
videokyc_flutter: ^1.0.3 copied to clipboard
A Flutter SDK for integrating SurePass Video KYC verification.
SurePass Video KYC Flutter SDK #
A Flutter SDK for integrating SurePass Video KYC verification into your mobile app.
Installation #
Add the dependency to your pubspec.yaml:
dependencies:
videokyc_flutter: ^1.0.3
Then fetch it:
flutter pub get
Platform setup #
The SDK requests these permissions at runtime, but it cannot declare them for you. You must add the entries below, or the requests will fail (and on iOS, a missing Info.plist key will crash the app).
Android #
Add the following to android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
Ensure your Android minSdk is 28 or higher. Recent Flutter projects use the Kotlin DSL — set minSdk = 28 in android/app/build.gradle.kts. Older Groovy projects use minSdkVersion 28 in android/app/build.gradle.
If your Android build fails on
proguard-android.txt. This SDK depends onflutter_inappwebview ^6.1.5, whose Android plugin does not build under Android Gradle Plugin 9 (the default in recent Flutter). If you hit an error like:getDefaultProguardFile('proguard-android.txt') is no longer supported since it includes -dontoptimize ...add this to your app's
pubspec.yaml(then runflutter pub get), untilflutter_inappwebview 6.2.0ships stable:dependency_overrides: flutter_inappwebview: 6.2.0-beta.3This is an app-level, temporary workaround —
dependency_overridesonly takes effect in the root app. Remove it onceflutter_inappwebview 6.2.0is published as stable: this SDK's^6.1.5constraint resolves to6.2.0automatically, so no SDK update is needed.
iOS #
Add the following keys to ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is required for video KYC verification.</string>
<key>NSMicrophoneUsageDescription</key>
<string>Microphone access is required for video KYC verification.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location access is required for video KYC verification.</string>
Set the minimum iOS version to 15.0 in ios/Podfile:
platform :ios, '15.0'
Required — enable the permissions this SDK uses. permission_handler ships with its iOS permissions disabled at compile time, so you must turn on camera, microphone, and location by adding the settings below to the post_install block in ios/Podfile. A Flutter app already has a post_install block — merge these lines into it (don't add a second one). Without this, the iOS permission prompts never appear and the flow ends immediately with VideoKycStatus.error:
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
'PERMISSION_CAMERA=1',
'PERMISSION_MICROPHONE=1',
'PERMISSION_LOCATION=1',
]
end
end
end
Usage #
Import the package and start the flow:
import 'package:flutter/material.dart';
import 'package:videokyc_flutter/videokyc_flutter.dart';
final result = await startSurepassVideoKyc(
context: context,
token: 'your_surepass_api_token',
env: Env.sandbox, // or Env.prod
workflowId: 'your_workflow_id',
email: 'user@example.com',
fullName: 'John Doe',
mobileNumber: '9876543210', // 10-digit number, no country-code prefix
onInitialized: (VideoKycModel model) {
// Fired once the Video KYC session is initialized.
debugPrint('User: ${model.userId}, session: ${model.sessionId}');
},
);
switch (result?.status) {
case VideoKycStatus.success:
debugPrint('KYC completed — session ${result!.sessionId}');
break;
case VideoKycStatus.cancelled:
debugPrint('KYC cancelled by the user');
break;
case VideoKycStatus.failed:
// Reserved — the current SDK surfaces failures as `error`, not `failed`.
debugPrint('KYC failed');
break;
case VideoKycStatus.error:
debugPrint('KYC error: ${result!.errorMessage}');
break;
case null:
debugPrint('Flow dismissed before reaching a terminal status');
break;
}
Parameters #
| Parameter | Required | Description |
|---|---|---|
context |
✅ | BuildContext used to push the KYC flow. |
token |
✅ | Your SurePass API authentication token. |
env |
✅ | Environment — Env.sandbox or Env.prod. |
workflowId |
✅ | Your SurePass workflow id. |
email |
✅ | User's email address. |
fullName |
✅ | User's full name. |
mobileNumber |
✅ | User's 10-digit mobile number (no country-code prefix). |
onInitialized |
— | Callback receiving the VideoKycModel when the session initializes. |
The VideoKycModel passed to onInitialized contains userId, workflowId, sessionId, videoKycUrl, and the optional workflowSessionId, eventType, and signature.
Result #
startSurepassVideoKyc() returns a SurepassVideoKycResult?. It is null if the flow is dismissed before reaching a terminal status; otherwise it exposes:
status—VideoKycStatus.success,cancelled, orerror. (VideoKycStatus.failedexists in the enum but is reserved and not currently emitted — failures surface aserror.)sessionId— the session id for tracking (when available).errorMessage— populated for setup and API failures whenstatusiserror; may benullfor in-flow WebView load errors.
Permissions #
These permissions must be declared in your app first (see Platform setup) — the SDK cannot add them for you:
- Camera — capturing video during verification.
- Microphone — audio during the video session.
- Location — location verification.
When the flow starts, the SDK requests any of these that aren't already granted, and the in-flow WebView re-requests them on demand if the verification page asks. If a required permission is denied, the flow ends with VideoKycStatus.error.
Error handling #
The returned status reflects how the flow ended, covering network errors, permission denials, API failures, and user cancellations. Handle each VideoKycStatus case (and the null "dismissed" case) as shown in Usage.
Requirements #
- Flutter
>=3.24.0(Dart>=3.5.0) — required byflutter_inappwebviewandpermission_handler. - Android API level 28 or higher — SurePass-recommended minimum for the WebView KYC experience.
- iOS 15.0 or higher — SurePass-recommended minimum (WebView camera capture needs a recent iOS).
Dependencies #
Built on top of flutter_inappwebview (WebView), permission_handler (runtime permissions), dio (networking), provider (state), plus json_annotation and equatable.
License #
Released under the MIT License — see LICENSE for details.