Flutter
This guide provides step-by-step instructions on integrating the IDV SDK into an Flutter application. It covers initialization, API configuration, workflow setup, and starting the ID verification process.
Before getting started, make sure you have installed the SDK.
Initialize
To start initialization, invoke:
import 'package:flutter_idv/flutter_idv.dart';
var (success, error) = await IDV.instance.initialize();
if (success) {
print("IDV SDK initialized successfully");
} else {
print("Initialization failed: $error");
}
Configure API Settings
Before using the SDK, configure the API connection using one of the following methods:
Username and password
var config = CredentialsConnectionConfig(
"your_host",
"your_username",
"your_password",
);
var (success, error) = await IDV.instance.configureWithCredentials(config);
if (success) {
print("Configured successfully");
} else {
print("Configuration failed: $error");
}
Token-based
var config = TokenConnectionConfig("your_token_url");
var (workflowIds, error) = await IDV.instance.configureWithToken(config);
if (workflowIds != null) {
print("Available workflows: $workflowIds");
} else {
print("Configuration failed: $error");
}
API key
var config = ApiKeyConnectionConfig(
"your_host",
"your_api_key",
);
var (success, error) = await IDV.instance.configureWithApiKey(config);
if (success) {
print("Configured successfully");
} else {
print("Configuration failed: $error");
}
Prepare and Start ID Verification Workflow
Retrieve available workflows
var (workflows, error) = await IDV.instance.getWorkflows();
if (workflows != null) {
print("Available workflows: $workflows");
} else {
print("Failed to fetch workflows: $error");
}
Prepare workflow
var config = PrepareWorkflowConfig("your_workflow_id");
var (workflow, error) = await IDV.instance.prepareWorkflow(config);
if (workflow != null) {
print("Workflow prepared: ${workflow.id}");
} else {
print("Failed to fetch workflows: $error");
}
Start workflow
var (result, error) = await IDV.instance.startWorkflow();
if (result != null) {
print("Workflow completed successfully, session ID: ${result.sessionId}");
} else {
print("Workflow failed: $error");
}
Optionally, you can pass a StartWorkflowConfig with metadata:
var config = StartWorkflowConfig(metadata: {"key": "value"});
var (result, error) = await IDV.instance.startWorkflow(config: config);
if (result != null) {
print("Workflow completed successfully, session ID: ${result.sessionId}");
} else {
print("Workflow failed: $error");
}
To start the workflow with a specific locale:
var config = StartWorkflowConfig(locale: "en");
var (result, error) = await IDV.instance.startWorkflow(config: config);
if (result != null) {
print("Workflow completed successfully, session ID: ${result.sessionId}");
} else {
print("Workflow failed: $error");
}
Deinitialize SDK
When the SDK is no longer needed (for example, on logout):
var (success, error) = await IDV.instance.deinitialize();
if (success) {
print("SDK deinitialized");
} else {
print("Failed to deinitialize: $error");
}
Best Practices and Troubleshooting
- Initialize the SDK before configuring or preparing workflows.
- Ensure camera permissions are granted before starting workflows.
- Use proper configuration when establishing a connection to the Platform.
- For production apps, implement secure storage for tokens and credentials.