Skip to main content
Version: 7.0.0

Get Started

This page will guide you through the process of adding ID Capture to your Flutter application. ID Capture is a mode of the Scandit Data Capture SDK that allows you to capture and extract information from personal identification documents, such as driver's licenses, passports, and ID cards.

The general steps are:

  • Creating a new Data Capture Context instance
  • Accessing a Camera
  • Configuring the Capture Settings
  • Implementing a Listener to Receive Scan Results
  • Setting up the Capture View and Overlay
  • Starting the Capture Process
warning

Using ID Capture at the same time as other modes (e.g. Barcode Capture) is not supported.

Prerequisites

Before starting with adding a capture mode, make sure that you have a valid Scandit Data Capture SDK license key and that you added the necessary dependencies. If you have not done that yet, check out this guide.

tip

You can retrieve your Scandit Data Capture SDK license key by signing in to your Scandit account.

Module Overview

The modules that need to be included in your project depend on the features you want to use. The following table lists what modules you need to include in your project, depending on the features you want to use.

ModuleRequired for Feature
ScanditCaptureCoreAlways
ScanditIdCaptureAlways
ScanditIdCaptureBackendExtract data from VIZ (e.g. front of IDs and driver licenses, human-readable data on Passport, etc.)
ScanditIdAamvaBarcodeVerificationVerify US Driver Licenses
ScanditIdVoidedDetectionReject voided IDs
tip

Note that your license may support only a subset all ID Capture capabilities. If you need to use additional features, contact us.

Initialize the ID Plugin

warning

Without initializing the ID plugin, runtime crashes will occur. However, you don’t have to initialize the core plugin, as initializing the ID plugin already does that.

Before accessing anything of the Scandit Data Capture SDK functionality. You have to initialize the id plugin.

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await ScanditFlutterDataCaptureId.initialize();
runApp(MyApp());
}

Create the Data Capture Context

The first step to add capture capabilities to your application is to create a new data capture context. The context expects a valid Scandit Data Capture SDK license key during construction.

var context = DataCaptureContext.forLicenseKey("-- ENTER YOUR SCANDIT LICENSE KEY HERE --");

Add the Camera

You need to also create the Camera:

Camera? camera = Camera.defaultCamera;

if (camera != null) {
// Use the settings recommended by id capture.
camera.applySettings(IdCapture.recommendedCameraSettings);
context.setFrameSource(camera);
}

Create ID Capture Settings

Use IdCaptureSettings to configure the scanner type and the accepted and rejected documents.

Check IdCaptureDocumentType for all the available options.

var settings = IdCaptureSettings();
settings.scannerType(
SingleSideScanner // To scan only one-sided documents
// or
FullDocumentScanner // To scan both sides of the document
);

settings.acceptedDocuments.addAll([PASSPORT, DRIVER_LICENSE]);
settings.rejectedDocuments.addAll([ID_CARD]);

Implement the Listener

To receive scan results, implement IdCaptureListener.

Capture results are delivered as a CapturedId. This class contains data common for all kinds of personal identification documents.

For more specific information, use its non-null result properties (e.g. CapturedId.barcode).


void didCaptureId(IdCapture idCapture, IdCaptureSession session) {
CapturedId? capturedId = session.newlyCapturedId;
// Do something in case the capturedId is not null.
}

Create a new ID Capture mode with the chosen settings. Then register the listener:

idCapture = IdCapture.forContext(context, settings);
idCapture.addListener(this)

Set up Capture View and Overlay

When using the built-in camera as frameSource, you will typically want to display the camera preview on the screen together with UI elements that guide the user through the capturing process.

To do that, add a DataCaptureView to your view hierarchy:

var dataCaptureView = DataCaptureView.forContext(dataCaptureContext);
// Add the dataCaptureView to your widget tree

Then create an instance of IdCaptureOverlay attached to the view:

overlay = IdCaptureOverlay.withIdCaptureForView(idCapture, dataCaptureView);

The overlay chooses the displayed UI automatically, based on the selected IdCaptureSettings.

If you prefer to show a different UI or to temporarily hide it, set the appropriate IdCaptureOverlay.idLayout.

Start the Capture Process

Finally, turn on the camera to start scanning:

camera.switchToDesiredState(FrameSourceState.on);