didit_sdk 3.4.1
didit_sdk: ^3.4.1 copied to clipboard
Didit Identity Verification SDK for Flutter. Wraps native iOS and Android SDKs for document scanning, NFC passport reading, face verification, and liveness detection.
DiditSDK for Flutter #
A Flutter plugin for Didit Identity Verification. Wraps the native iOS and Android SDKs with a unified Dart API for document scanning, NFC passport reading, face verification, and liveness detection.
Requirements #
| Requirement | Minimum Version |
|---|---|
| Flutter | 3.3+ |
| Dart | 3.11+ |
| iOS | 13.0+ (NFC requires iOS 15.0+) |
| Android | API 23+ (6.0 Marshmallow) |
Installation #
Add the dependency to your pubspec.yaml:
dependencies:
didit_sdk: ^3.4.0
Then run:
flutter pub get
iOS Setup #
Add the DiditSDK podspec to your ios/Podfile (it's not on CocoaPods trunk):
# Inside your target block:
pod 'DiditSDK', :podspec => 'https://raw.githubusercontent.com/didit-protocol/sdk-ios/main/DiditSDK.podspec'
Then install dependencies:
cd ios
pod install
Android Setup #
Add the following packaging rule to your android/app/build.gradle.kts inside the android block:
android {
packaging {
resources {
pickFirsts += "META-INF/versions/9/OSGI-INF/MANIFEST.MF"
}
}
}
This resolves a duplicate metadata file shipped by the SDK's cryptography dependencies (BouncyCastle). Without it the build will fail with a mergeDebugJavaResource error.
Permissions #
iOS #
Add the following keys to your app's Info.plist:
| Permission | Info.plist Key | Description | Required |
|---|---|---|---|
| Camera | NSCameraUsageDescription |
Document scanning and face verification | Yes |
| NFC | NFCReaderUsageDescription |
Read NFC chips in passports/ID cards | If using NFC |
| Location | NSLocationWhenInUseUsageDescription |
Geolocation for fraud prevention | Optional |
<key>NSCameraUsageDescription</key>
<string>Camera access is required for identity verification.</string>
<key>NFCReaderUsageDescription</key>
<string>NFC is used to read passport chip data for identity verification.</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location access is used to detect your country for identity verification.</string>
NFC Configuration (for passport/ID chip reading)
-
Add NFC Capability in Xcode:
- Select your target > Signing & Capabilities > + Capability > Near Field Communication Tag Reading
-
Add ISO7816 Identifiers to
Info.plist:<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key> <array> <string>A0000002471001</string> </array>
Android #
The following permissions are declared in the native SDK's AndroidManifest.xml and merged automatically:
| Permission | Description | Required |
|---|---|---|
INTERNET |
Network access for API communication | Yes |
ACCESS_NETWORK_STATE |
Detect network availability | Yes |
CAMERA |
Document scanning and face verification | Yes |
NFC |
Read NFC chips in passports/ID cards | If using NFC |
Camera and NFC hardware features are declared as optional (android:required="false"), so your app can be installed on devices without these features.
Runtime Permissions
The SDK handles Android runtime permission requests automatically. When the user reaches a step that requires camera access:
- The SDK prompts for camera permission if not already granted
- If the user denies the permission, an error message is displayed with a "Try Again" button
- If the user grants the permission, the verification flow continues
You do not need to request camera permission in your app code before calling startVerification() — the SDK manages this internally.
Quick Start #
import 'package:didit_sdk/sdk_flutter.dart';
final result = await DiditSdk.startVerification('your-session-token');
switch (result) {
case VerificationCompleted(:final session):
print('Status: ${session.status}');
print('Session ID: ${session.sessionId}');
case VerificationCancelled():
print('User cancelled');
case VerificationFailed(:final error):
print('Error: ${error.type} - ${error.message}');
}
Integration Methods #
The SDK supports two integration methods:
Method 1: API Integration (Recommended for Production) #
Your backend creates a session via the Didit API and returns the session token. This gives you full control over session creation, user tracking, and security.
Read more about how the create session API works here: https://docs.didit.me/reference/create-session-verification-sessions
// Your backend creates a session and returns the token
final sessionToken = await yourBackend.createVerificationSession(userId);
// Pass the token to the SDK
final result = await DiditSdk.startVerification(sessionToken);
This approach gives you full control over:
- Associating sessions with your users (
vendor_data) - Setting contact details, expected details, and metadata
- Configuring callbacks per session
Method 2: Unilink Integration (Simpler) #
For simpler integrations, the SDK can create sessions directly using your workflow ID — no backend needed:
final result = await DiditSdk.startVerificationWithWorkflow(
'your-workflow-id',
vendorData: 'user-123',
config: DiditConfig(loggingEnabled: true),
);
Note: Advanced session parameters (
contact_details,expected_details,metadata) are only available through the API Integration method, where your backend calls the Create Session API directly.
Configuration #
Customize the SDK behavior by passing a DiditConfig object:
final result = await DiditSdk.startVerification(
'your-session-token',
config: DiditConfig(
languageCode: 'es', // Force Spanish language
fontFamily: 'Avenir', // Custom font
loggingEnabled: true, // Debug logging
),
);
Configuration Options #
| Option | Type | Default | Description |
|---|---|---|---|
languageCode |
String? |
Device locale | ISO 639-1 language code (e.g. "en", "fr", "ar") |
fontFamily |
String? |
System font | Custom font family name |
loggingEnabled |
bool |
false |
Enable SDK debug logging |
All fields are optional. If no config is provided, the SDK uses sensible defaults.
languageCode #
Sets the language for the entire verification UI. Pass an ISO 639-1 code (e.g. "en", "fr", "es", "ar"). If not set, the SDK automatically detects the device locale and falls back to English.
// Force French
await DiditSdk.startVerification(token, config: DiditConfig(languageCode: 'fr'));
// Use device locale (default)
await DiditSdk.startVerification(token);
fontFamily #
Overrides the font used throughout the SDK UI. The font must be registered in your app's native configuration:
- iOS: Add the font file to your Xcode project and list it in
Info.plistunderUIAppFonts. - Android: Place the font file in
android/app/src/main/res/font/.
await DiditSdk.startVerification(token, config: DiditConfig(fontFamily: 'Avenir'));
loggingEnabled #
Enables verbose debug logging from the native SDK. Useful during development to inspect the SDK's internal state, API calls, and error details. Should be disabled in production.
await DiditSdk.startVerification(token, config: DiditConfig(loggingEnabled: true));
Language Support #
The SDK supports 40+ languages. If no language is specified, the SDK uses the device locale with English as fallback.
Supported Languages
| Language | Code | Language | Code |
|---|---|---|---|
| English | en |
Korean | ko |
| Arabic | ar |
Lithuanian | lt |
| Bulgarian | bg |
Latvian | lv |
| Bengali | bn |
Macedonian | mk |
| Catalan | ca |
Malay | ms |
| Czech | cs |
Dutch | nl |
| Danish | da |
Norwegian | no |
| German | de |
Polish | pl |
| Greek | el |
Portuguese | pt |
| Spanish | es |
Portuguese (Brazil) | pt-BR |
| Estonian | et |
Romanian | ro |
| Persian | fa |
Russian | ru |
| Finnish | fi |
Slovak | sk |
| French | fr |
Slovenian | sl |
| Hebrew | he |
Serbian | sr |
| Hindi | hi |
Swedish | sv |
| Croatian | hr |
Thai | th |
| Hungarian | hu |
Turkish | tr |
| Armenian | hy |
Ukrainian | uk |
| Indonesian | id |
Uzbek | uz |
| Italian | it |
Vietnamese | vi |
| Japanese | ja |
Chinese (Simplified) | zh |
| Georgian | ka |
Chinese (Traditional) | zh-TW |
| Montenegrin | cnr |
Somali | so |
Advanced Session Parameters #
Parameters like contact_details, expected_details, and metadata are only supported through the API Integration method. Your backend creates the session with full parameter support, then passes the session_token to the SDK.
Read more about how the create session API works here: https://docs.didit.me/reference/create-session-verification-sessions
// Your backend handles the full session creation:
// POST /v3/session/ with contact_details, expected_details, metadata, etc.
final sessionToken = await yourBackend.createSession(userId);
// The SDK only needs the token
final result = await DiditSdk.startVerification(sessionToken);
Verification Results #
Both startVerification and startVerificationWithWorkflow return a Future<VerificationResult>. The result is a sealed class — use pattern matching to determine the outcome.
Result Types #
| Type | Description | Fields |
|---|---|---|
VerificationCompleted |
Verification flow completed | session (always present) |
VerificationCancelled |
User cancelled the flow | session (optional) |
VerificationFailed |
An error occurred | error (always present), session (optional) |
SessionData #
| Property | Type | Description |
|---|---|---|
sessionId |
String |
The unique session identifier |
status |
VerificationStatus |
approved, pending, or declined |
VerificationError #
| Property | Type | Description |
|---|---|---|
type |
VerificationErrorType |
Error category (see table below) |
message |
String |
Human-readable error description |
Error Types #
| Error Type | Description |
|---|---|
sessionExpired |
The session has expired |
networkError |
Network connectivity issue |
cameraAccessDenied |
Camera permission not granted |
notInitialized |
SDK not initialized (Android only) |
apiError |
API request failed |
unknown |
Other error with message |
Complete Result Handling Example #
import 'package:didit_sdk/sdk_flutter.dart';
Future<void> verify(String token) async {
final result = await DiditSdk.startVerification(token);
switch (result) {
case VerificationCompleted(:final session):
switch (session.status) {
case VerificationStatus.approved:
print('Approved! Session: ${session.sessionId}');
// User is verified — grant access
case VerificationStatus.pending:
print('Under review. Session: ${session.sessionId}');
// Show "verification in progress" UI
case VerificationStatus.declined:
print('Declined. Session: ${session.sessionId}');
// Handle declined verification
}
case VerificationCancelled(:final session):
print('User cancelled.');
if (session != null) {
print('Session: ${session.sessionId}');
}
// Maybe show retry option
case VerificationFailed(:final error):
print('Error [${error.type}]: ${error.message}');
// Handle error — show retry or contact support
}
}
API Reference #
DiditSdk.startVerification(token, {config}) #
Start verification with an existing session token.
| Parameter | Type | Required | Description |
|---|---|---|---|
token |
String |
Yes | Session token from the Didit API |
config |
DiditConfig? |
No | SDK configuration options |
Returns: Future<VerificationResult>
DiditSdk.startVerificationWithWorkflow(workflowId, {...}) #
Start verification by creating a new session with a workflow ID (Unilink Integration).
| Parameter | Type | Required | Description |
|---|---|---|---|
workflowId |
String |
Yes | Workflow ID that defines verification steps |
vendorData |
String? |
No | Your user identifier or reference |
config |
DiditConfig? |
No | SDK configuration options |
Returns: Future<VerificationResult>
Running the Example App #
The repository includes a fully functional example app.
iOS #
cd example
flutter pub get
cd ios && pod install && cd ..
flutter run
To run on a real device, open example/ios/Runner.xcworkspace in Xcode, configure your signing team, and select your device.
Android #
cd example
flutter pub get
flutter run
License #
Copyright (c) 2026 Didit. All rights reserved.