smartverify_biometric
Official Flutter SDK for SmartVerifyNG Biometric Facial Capture & Liveness Verification.
Guide users through real-time on-device liveness checks (face alignment, smile, and blink detection) and automatically submit the captured face to the SmartVerifyNG Liveness Check API (POST /api/v1/verify/liveness).
Preview
Security-First Webhook Architecture
Because client mobile apps embed a public key (pk_...), exposing liveness scores or verification decisions directly to the client would allow someone who extracts a public key to run unauthorized liveness checks at the key owner's expense.
To protect developers:
- The SDK authenticates using your public key via the
X-PUBLIC-KEYheader and rejects secret keys (sk_...) at initialization. onCompletereturns only the safe submission status (status,isSuccess), the clear providermessage, and thereference(plus optional locally captured image bytes).- The full liveness verdict, confidence score, and anti-spoofing checks are never returned to the client SDK — SmartVerify delivers them exclusively to your configured server-side webhook, which you correlate using
reference.
Features
- Public-Key Authentication (
X-PUBLIC-KEY): Rejectssk_...secret keys automatically. - Guided On-Device Active Liveness + Voice Prompts: Circular face viewport with animated instructions, spoken Text-to-Speech voice guidance (with mute/unmute toggle), face centering/pose validation, sustained smile verification, and blink verification powered by Google ML Kit.
- Instant Direct-Face Capture: Captures the user's aligned direct face straight from the live stream during the smile/open-eyes liveness moment with zero post-blink shutter lag.
- Webhook-Only Verdict Protection: Client callback receives only status, reference, and clear provider message; full scores & anti-spoofing results go strictly to your webhook.
- Customizable UI, Voice & Retry Handling: Configure titles, copy, voice language/rate, thresholds, error retries, and theming via
SmartVerifyCaptureOptionsandSmartVerifyTheme.
Installation
Add smartverify_biometric to your pubspec.yaml:
dependencies:
smartverify_biometric: ^1.0.0
Then run:
flutter pub get
Platform Setup
Android
- Ensure
minSdkis at least21inandroid/app/build.gradle(orbuild.gradle.kts). - Add the camera permission to
android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.front" android:required="false" />
iOS
- Set the minimum iOS deployment target to
15.5or higher inios/Podfile(required bygoogle_mlkit_face_detection). - Add
NSCameraUsageDescriptiontoios/Runner/Info.plist:
<key>NSCameraUsageDescription</key>
<string>Camera access is required to capture your face for biometric liveness verification.</string>
Quick Start
1. Initialize with your Public Key
Initialize the SDK once (e.g. in main()):
import 'package:smartverify_biometric/smartverify_biometric.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
SmartVerifyBiometric.initialize(
publicKey: 'pk_live_your_public_key_here',
defaultThreshold: 65.0, // optional (API default: 65.0)
);
runApp(const MyApp());
}
Security Note: Never pass a secret key (
sk_live_.../sk_test_...) in your Flutter app.SmartVerifyBiometric.initializethrows anArgumentErrorif a secret key is supplied.
2. Launch Biometric Capture & Handle onComplete
await SmartVerifyBiometric.instance.startLivenessCheck(
context: context,
reference: 'TXN_LIVE_CHECK_001', // pass your unique reference to match the webhook
onComplete: (SmartVerifyLivenessResult result) {
if (result.isSuccess) {
// Capture was accepted by SmartVerify.
// Poll your backend or wait for your server webhook using result.reference.
debugPrint('Submitted (${result.reference}): ${result.message}');
} else {
// Submission failed — display or log the clear provider message.
debugPrint('Error (${result.errorCode}): ${result.message}');
}
},
onCancel: () {
debugPrint('User closed biometric capture before completion.');
},
);
3. Embed SmartVerifyCaptureScreen Directly (Optional)
If you use GoRouter or custom navigation, render SmartVerifyCaptureScreen directly:
SmartVerifyCaptureScreen(
reference: 'TXN_LIVE_CHECK_002',
options: const SmartVerifyCaptureOptions(
title: 'Verify Your Identity',
allowRetryOnError: true,
),
theme: const SmartVerifyTheme(
primaryColor: Color(0xFF059669),
),
onComplete: (result) {
// Proceed with your app flow; consume the full verdict from your webhook.
},
);
SmartVerifyLivenessResult Overview
| Property | Type | Description |
|---|---|---|
status |
String |
API response status string (e.g. success, error). |
isSuccess |
bool |
Whether the capture was accepted by the SmartVerify API (HTTP 2xx). |
message |
String |
Clear human-readable response message returned by the SmartVerify API. |
reference |
String? |
Transaction reference to correlate with the full webhook payload on your backend. |
service |
String? |
Service identifier returned by the API (e.g. liveness_check). |
httpStatusCode |
int? |
HTTP status code from the SmartVerify API. |
errorCode |
SmartVerifyErrorCode? |
Categorized SDK error code when isSuccess is false. |
capturedImageBytes |
Uint8List? |
Locally captured JPEG bytes (when includeCapturedImage: true). |
capturedImageBase64 |
String? |
Locally captured Base64 image (when includeCapturedImage: true). |
Documentation
For full SmartVerifyNG API and webhook documentation, visit: https://smartverifyng.com/docs#liveness-check
Libraries
- smartverify_biometric
- Flutter biometric facial capture and anti-spoofing liveness verification SDK for SmartVerifyNG.