Flutter SDK for Sotaid
A Flutter plugin for SotaID identity verification integration.
Features
- App-Controlled Verification Process: The app decides whether to show complete verification (document + face) or face-only verification
- Multiple Verification Types: Support for ID verification, face matching, and liveness detection
- Document Capture: Capture front and back of identity documents
- Face Verification: Record face videos for verification
- Permission Management: Automatic camera and storage permission handling
- Country Support: Dynamic country and document type selection
- Session Management: Automatic storage and reminder for pending manual verifications
Getting Started
Installation
Add the plugin to your pubspec.yaml:
Basic Usage
App-Controlled Verification (Recommended)
The verification process selection is now controlled by the app, not the user. The app decides whether to show the complete verification process or just face verification.
import 'package:sotaid_pluging/sotaid_plugin.dart';
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final SotaIdPlugin _plugin = SotaIdPlugin();
// Start complete verification (document + face)
Future<void> _startCompleteVerification() async {
await _plugin.startCompleteVerification(
context: context,
bearerToken: 'your_bearer_token',
onVerificationComplete: (response) {
print('Verification completed: ${response.status}');
// Handle successful verification
},
onError: (error) {
print('Verification error: $error');
// Handle verification error
},
);
}
// Start face-only verification (requires document file)
Future<void> _startFaceVerification() async {
// In a real app, you would get this file from user selection or capture
File documentFile = await _getDocumentFile();
await _plugin.startFaceVerification(
context: context,
documentFile: documentFile,
bearerToken: 'your_bearer_token',
onVerificationComplete: (response) {
print('Face verification completed: ${response.status}');
// Handle successful verification
},
onError: (error) {
print('Face verification error: $error');
// Handle verification error
},
);
}
// Generic verification flow with custom verification type
Future<void> _startCustomVerification() async {
await _plugin.startVerificationFlow(
context: context,
verificationType: VerificationType.id, // or VerificationType.facematch, VerificationType.liveness
documentFile: null, // Required only for VerificationType.facematch
bearerToken: 'your_bearer_token',
onVerificationComplete: (response) {
print('Verification completed: ${response.status}');
},
onError: (error) {
print('Verification error: $error');
},
);
}
// Manually check verification status
Future<void> _checkVerificationStatus() async {
await _plugin.checkPendingVerificationStatus(context);
}
}
Legacy Verification Flow
The legacy verification flow still allows direct access to the verification widget, but now requires the verification type to be specified by the app:
import 'package:sotaid_pluging/verification_flow.dart';
// Show verification flow with app-controlled verification type
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SotaIdVerificationFlow(
verificationType: VerificationType.id, // App controls the verification type
bearerToken: 'your_bearer_token',
documentFile: null, // Required only for VerificationType.facematch
onVerificationComplete: (response) {
print('Verification completed: ${response.status}');
},
onError: (error) {
print('Verification error: $error');
},
),
),
);
Verification Types
Complete Verification (VerificationType.id)
- User captures document front (and back if required)
- User records face video
- Full identity verification process
Face Verification (VerificationType.facematch)
- App provides a reference document file
- User only records face video
- Face is compared against the provided document
Liveness Detection (VerificationType.liveness)
- User records face video
- System detects if the person is real (not a photo/video)
API Reference
SotaIdPlugin
Methods
startCompleteVerification()- Start complete verification flowstartFaceVerification()- Start face-only verification flowstartVerificationFlow()- Start verification with custom typeinitialize()- Initialize plugin with configurationgetCountries()- Get available countriescreateVerificationSession()- Create verification sessionverifyFront()- Verify document frontverifyBack()- Verify document backverifyFace()- Verify face videogetVerificationStatus()- Get verification status
VerificationResponse
class VerificationResponse {
final String status; // 'verified', 'requires_back', 'requires_face', 'failed', etc.
final Map<String, dynamic>? errors;
final String? message;
}
Configuration
Bearer Token
The plugin requires a bearer token for API authentication. This should be provided by your app:
_plugin.initialize(bearerToken: 'your_bearer_token');
Environment Mode
The plugin defaults to sandbox mode. You can change this during initialization:
_plugin.initialize(
sandboxMode: false, // Set to false for production
bearerToken: 'your_bearer_token',
);
Permissions
The plugin automatically handles camera and storage permissions. Users will be prompted for permissions when needed during the verification process.
Session Management
The plugin automatically manages verification sessions, especially for manual verification processes:
Automatic Session Storage
- When a verification returns
requires_manual_verificationstatus, the session is automatically stored locally - Session information includes session ID, status, and creation timestamp
Pending Verification Reminder
- When users try to start a new verification, the plugin checks for existing pending verifications
- If a pending manual verification exists, users are prompted with options:
- "Vérifier le statut": Check the current status of the pending verification
- "Nouvelle vérification": Start a new verification process
Status Checking
- Users can check the status of pending verifications
- The plugin fetches the latest status from the server
- Shows appropriate messages based on current status:
- ✅ Verified: Success message with option to clear session
- ❌ Failed: Error message with option to start new verification
- ⏰ Pending: Shows time since submission with current status
Automatic Cleanup
- Sessions are automatically cleared when verification completes (success or failure)
- No manual cleanup required
Example
See the example/ directory for a complete working example demonstrating both the new app-controlled verification API and the legacy verification flow.
Migration from Previous Versions
If you were using the previous version where users could choose verification types:
- Remove verification type selection UI from your app
- Use the new app-controlled API (
startCompleteVerification()orstartFaceVerification()) - Decide verification type in your app logic based on your business requirements
- Update your verification flow calls to include the required
verificationTypeparameter
License
This project is licensed under the MIT License - see the LICENSE file for details.
Libraries
- flows/facematch_verification_flow
- flows/flows
- flows/full_verification_flow
- flows/liveness_verification_flow
- flows/shared/corner_brackets_painter
- flows/shared/custom_camera_widget
- flows/shared/custom_face_recording_widget
- flows/shared/face_capture_widget
- flows/shared/face_outline_painter
- flows/shared/image_preview_screen
- flows/shared/powered_by_widget
- flows/shared/video_preview_page
- sotaid_plugin
- sotaid_pluging
- sotaid_pluging_method_channel
- sotaid_pluging_platform_interface
- verification_flow