Flutter Verification SDK
Official Flutter SDK for identity verification with WebView integration. Add document and liveness verification to your Flutter app with just a few lines of code.
Open Source on GitHub
View source code, examples, and detailed integration guides
Key Features
Secure
API key stays on your backend server
Cross-platform
Works on Android and iOS
Customizable
Configure base URL, auto-close, and other settings
Easy Integration
Simple API with just a few lines of code
Full Verification
Document capture and liveness detection
Auto-close
Automatic WebView closing after verification
Installation
Add the Flutter Verification SDK to your project's pubspec.yaml file:
pubspec.yaml
dependencies:
flutter_verification_sdk: ^0.1.0Then run:
flutter pub get
flutter clean # Recommended to ensure proper manifest mergingPlatform Setup
Android
The SDK automatically includes required permissions and FileProvider configuration. Verify your android/app/build.gradle has:
minSdkVersion 21Note: The SDK's AndroidManifest.xml automatically merges with your app's manifest, including camera, internet, and storage permissions, plus FileProvider for camera capture.
iOS
Add the following to your ios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is required for document and liveness verification</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo library access to upload document images</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location verification for identity confirmation</string>Quick Start
Security Best Practice
Never include your API key in your mobile app. Always generate the verification ID on your secure backend server.
Step 1: Get a verification ID from your backend
// Call YOUR backend endpoint
final response = await http.post(
Uri.parse('https://your-api.com/generate-verification'),
headers: {'Authorization': 'Bearer $yourAuthToken'},
);
final data = jsonDecode(response.body);
final verificationId = data['verificationId'];Step 2: Start the verification
import 'package:flutter_verification_sdk/flutter_verification_sdk.dart';
final result = await VerificationSDK.startVerification(
context: context,
verificationId: verificationId,
config: VerificationConfig.production(), // Auto-closes after 2 seconds
);
// Handle the result
if (result.isSuccessful) {
print('Verification completed!');
print('Status: ${result.verificationStatus}');
// Update your UI, notify backend, navigate to next screen, etc.
} else if (result.wasCancelled) {
print('User cancelled');
} else if (result.hasError) {
print('Error: ${result.errorMessage}');
}Configuration Options
Environment Configuration
// Production environment (auto-closes after 2 seconds)
VerificationConfig.production()
// Staging environment
VerificationConfig.staging()
// Custom configuration with auto-close
VerificationConfig(
baseUrl: 'https://your-custom-url.com',
debugMode: true,
timeout: Duration(minutes: 30),
autoClose: true, // Automatically close after completion
autoCloseDelay: Duration(seconds: 3), // Wait 3 seconds before closing
)
// Disable auto-close (user must manually close)
VerificationConfig(
baseUrl: 'https://verify.test.okid.io',
autoClose: false, // Stay on result screen, user closes manually
)Auto-Close Behavior
By default, the SDK automatically closes the WebView 2 seconds after verification completes, allowing users to see the success/failure status briefly.
autoClose: true(default) - WebView closes automatically after autoCloseDelayautoClose: false- WebView stays open on result screen, user closes manuallyautoCloseDelay- Duration to show result before auto-closing (default: 2 seconds)
Viewport Scaling
The SDK uses 95% initial scale by default to ensure content fits without scrolling on mobile screens.
VerificationConfig(
baseUrl: 'https://verify.test.okid.io',
initialScale: 100, // Use 100% if you prefer no scaling
)Verification Result
The VerificationResult object contains:
status- The outcome (completed, cancelled, error, expired)verificationId- The verification IDverificationStatus- Backend status (e.g., "verified", "rejected")errorMessage- Error details if status is errortimestamp- When the result was received
Convenience Properties
isSuccessful- True if verification completedwasCancelled- True if user cancelledhasError- True if an error occurredisExpired- True if session timed out
Backend Integration
Your backend server must provide an endpoint that generates verification IDs. The SDK repository includes detailed backend implementation examples in various languages.
Quick Example (Node.js)
app.post('/api/mobile/generate-verification', async (req, res) => {
const response = await fetch('https://verify.test.okid.io/api/generate-verification', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-SDK-Key': process.env.OKID_API_KEY, // Your API key - server-side only!
},
body: JSON.stringify({
extra_data: {
user_id: req.user.id,
}
}),
});
const data = await response.json();
res.json({ verificationId: data.verificationId });
});Complete Backend Integration Guide
For detailed backend implementation examples in Node.js, Python, PHP, and more, see the INTEGRATION.md file in the GitHub repository.
Security Best Practices
✅ Do
- Generate verification IDs on your backend server
- Store your API key securely on your server
- Authenticate users before generating verification IDs
❌ Don't
- Include your API key in your mobile app
- Call the verification API directly from your app
- Commit API keys to version control
Troubleshooting
Camera permissions not working
- Android: Check
minSdkVersion 21or higher, runflutter clean - iOS: Add camera usage descriptions to Info.plist
WebView not loading
- Ensure you have internet permission
- Check that the base URL is correct
- Enable debug mode to see detailed logs
Verification fails to start
- Verify the verification ID is valid and not expired
- Check your backend is generating IDs correctly
- Ensure your API key is valid