Flutter SDK Guide
The official prembly_identity_kyc package for Flutter allows you to launch identity verification, biometric capture, and liveness challenges across iOS, Android, and Web apps using native Dart bindings.
Installation
Add the latest version of the package from your project root:
flutter pub add prembly_identity_kycOr add it to your project's pubspec.yaml file manually:
dependencies:
flutter:
sdk: flutter
prembly_identity_kyc: ^0.1.3Then run the pub command to fetch the dependency:
flutter pub getNative Platform Permissions Setup
iOS Configuration (ios/Runner/Info.plist)
Open ios/Runner/Info.plist and append the camera and microphone permission keys:
<key>NSCameraUsageDescription</key>
<string>This app requires access to the camera for identity document scanning and biometric liveness verification.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app requires access to the microphone for liveness checks.</string>iOS Podfile (ios/Podfile)
The SDK asks for the camera and microphone through permission_handler, which leaves each permission out of the iOS build unless you switch it on. Without this step, iOS refuses camera access without ever showing a prompt.
In ios/Podfile, inside post_install:
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',
]
end
end
endThen run pod install from the ios directory.
iOS Simulator Limitation
The camera hardware module is unavailable on iOS Simulators. Always test identity verification and face liveness flows on a physical iOS device.
Android Configuration (android/app/src/main/AndroidManifest.xml)
Open android/app/src/main/AndroidManifest.xml and add these permissions just above the <application> tag:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />Web
No extra configuration is required. The browser asks for camera access when the flow starts.
Implementation Example
Import the library and invoke PremblyIdentityKyc.verify() with your IdentityKycOptions:
import 'package:flutter/material.dart';
import 'package:prembly_identity_kyc/prembly_identity_kyc.dart';
class IdentityVerificationScreen extends StatelessWidget {
const IdentityVerificationScreen({Key? key}) : super(key: key);
void startVerification(BuildContext context) {
PremblyIdentityKyc.verify(
context: context,
options: IdentityKycOptions(
widgetKey: 'wk_live_abc123xyz789',
widgetId: '550e8400-e29b-41d4-a716-446655440000',
firstName: 'John',
lastName: 'Doe',
email: 'john@example.com',
callback: (response) {
debugPrint('Prembly Response: $response');
if (response['status'] == 'success') {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Identity Verified Successfully!')),
);
} else {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Verification Closed or Failed')),
);
}
},
),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Identity Verification')),
body: Center(
child: ElevatedButton(
onPressed: () => startVerification(context),
child: const Text('Verify Identity'),
),
),
);
}
}IdentityKycOptions Parameter Reference
| Parameter | Type | Required | Description |
|---|---|---|---|
widgetKey | String | Yes | Your public SDK key from the Prembly dashboard. |
widgetId | String | Yes | The verification workflow configuration ID created in your dashboard. |
firstName | String | Yes | The user's first name. |
lastName | String | Yes | The user's last name. |
email | String | Yes | The user's email address. |
phone | String | Optional | The user's phone number. |
metadata | Map<String, dynamic> | Optional | Custom key-value pairs returned in callbacks, the session lookup, and webhooks. |
collectDeviceData | bool | Optional | Defaults to true. Reads the phone's own device ID and details and passes them to the widget, so device checks see the real device. No permission prompt is shown and location is never read. Set to false to use only what the web page can see. Mobile only. |
callback | void Function(Map<String, dynamic>) | Optional | Receives a Map with a status key. See Callback statuses. |
Callback statuses
status | When | Other keys |
|---|---|---|
success | Verification finished. The flow closes. | data: the session payload. |
closed | The user closed the flow. | — |
error | The widget reported an error. The flow closes. | message |
error_display_closed | The SDK showed an error screen (for example, camera access denied) and the user dismissed it. | — |
Any other event the widget reports is passed to callback as status with its data, and the flow stays open. Don't treat an unrecognised status as the end of the session.
Don't update your records from callback alone. Use webhooks as the source of truth.
To skip the ID screen with a known BVN or NIN, use PremblyWorkflow instead.
Run a Workflow (PremblyWorkflow)
PremblyWorkflow.start() runs one of your compliance workflows in the app. It uses your workflow ID and publishable key instead of a widget key and widget ID. Requires 0.1.3 or later.
import 'package:prembly_identity_kyc/prembly_identity_kyc.dart';
void startOnboarding(BuildContext context) {
PremblyWorkflow.start(
context: context,
options: WorkflowOptions(
publishableKey: 'test_pk_...',
workflowId: 'wf_123',
customer: const WorkflowCustomer(
firstName: 'John',
lastName: 'Doe',
email: 'john@example.com',
),
metadata: {'user_id': '123456'},
// Optional: a BVN or NIN you already have, so they skip the ID screen
prefill: const WorkflowPrefill(bvn: '22212345678'),
callback: (result) {
debugPrint('Workflow ended: ${result.status}');
},
),
);
}iOS and Android only. On the web, callback receives failed with errorCode not_available. The camera and microphone are asked for only when a step needs them.
WorkflowOptions Parameter Reference
| Parameter | Type | Required | Description |
|---|---|---|---|
publishableKey | String | Yes | Your publishable key: live_pk_... or test_pk_.... A secret key is refused. |
workflowId | String | Yes | The workflow to run (wf_...), from your workflows list in the dashboard. |
customer | WorkflowCustomer | Yes | The person going through the workflow: firstName, lastName, email (required), phone, reference (your own reference for them). |
callback | void Function(WorkflowResult) | Yes | Called once when the flow ends. See Workflow results. |
prefill | WorkflowPrefill | Optional | A BVN or NIN you already have. The customer skips the ID screen. See Prefill an ID number. |
metadata | Map<String, dynamic> | Optional | Your own data, stored with the run. |
redirectUrl | String | Optional | Where to send the customer when the workflow finishes. |
collectDeviceData | bool | Optional | Defaults to true. Passes the phone's device ID and details to the workflow, so its device checks see the real device. No permission prompt is shown. |
onEvent | void Function(WorkflowEvent) | Optional | Called for every event the workflow reports, with type, sessionId and nodeId. Contains no personal data. |
Workflow results
callback receives a WorkflowResult with status and, once a session exists, sessionId:
status | Meaning |
|---|---|
completed | The workflow finished. |
failed | The workflow ended in failure. If it could not start at all, sessionId is empty and errorCode and errorMessage say why: invalid_key, invalid_request, unauthorised, not_found, rate_limited, server_error, network_error, timeout or not_available. |
manual_review | The workflow ended and is waiting for a reviewer. |
expired | The session expired before the customer finished. |
cancelled | The customer closed the flow before it ended. lastEvent is the last event seen; processing means they finished their steps and the checks continue in the background. |
As with the widget, use webhooks for the final outcome.
Troubleshooting (Flutter)
- Build Failure on Android: The plugin builds against
compileSdk36 and needsminSdk24 or higher. Check both inandroid/app/build.gradle. - Camera Denied on iOS Without a Prompt: The
PERMISSION_CAMERA=1andPERMISSION_MICROPHONE=1flags are missing fromios/Podfile. See iOS Podfile, then runpod installagain. - Camera Crash on iOS: Confirm that
NSCameraUsageDescriptionis present inInfo.plist. iOS terminates applications immediately if camera access is requested without a description string.
React Native SDK
Integrate Prembly's identity verification, biometric liveness, and document capture SDK into cross-platform React Native mobile applications.
Ionic (Capacitor) SDK
Integrate Prembly's identity verification widget and compliance workflows into Ionic and Capacitor apps on iOS and Android.