Document Capture (Flutter)

Estimated reading: 3 minutes 236 views

AwareID Document Capture allows for authentication and verification of various documents including:

  • Passports
  • Drivers' Licenses
  • National IDs

The package currently performs document scans via optical character recognition using an on device camera and RFID scan using NFC.

Requirements

  • iOS 11.0 and above
  • Android API level 21

Both platform will also need camera permissions set.

For iOS an entry must be made in the info.plist to gain camera and NFC hardware permissions

<key>NSCameraUsageDescription</key>
<string>Is used to access your device's camera</string>

<key>NFCReaderUsageDescription</key>
<string>Is used to access your device's NFC</string>

For android the below lines must be added to gain camera and NFC hardware permissions in the Android Manifest

<uses-feature android:name="android.hardware.camera"/>   

<uses-permission android:name="android.permission.CAMERA"/>

<uses-permission android:name="android.permission.NFC" />

Installation

Installation of the AwareID Document Capture Package is done in 2 steps:
1) Copy the document_capture folder to a desired location within your project.
2) Reference the document_capture package in your project's pubspec.yaml file under dependencies

dependencies:
  flutter:
    sdk: flutter
    ...
    ...
  document_capture:
    path: document_capture

The above example has the "document_capture" folder at the root of the project folder.

dependencies:
  flutter:
    sdk: flutter
    ...
    ...
  document_capture:
    path: repo/document_capture

The above example has the "document_capture" folder in a folder called "repo" at the root of the project folder.

Once the folder is in the desired location within the project and the document_capture sdk referenced in the pubspec.yaml then perfrom a flutter pub get

Getting started

Firstly you need to import the package in your dart code:

import 'package:document_capture/document_capture.dart';

The AwareID Document Capture SDK requires our database of documents from our server to operate.
There are two ways of retrieving this database, both of which require an internet connection:
1) Download the newest version of the database only if the current one is incompatible with the package.

AWDocumentCapture.downloadDatabase();

2) Download the newest version of the database if one is available even if your current database is still compatible with the package.

AWDocumentCapture.autoDownloadDatabase();

Usage

Once the Document Capture database has been downloaded we can then call start capture to run the document capture process.

AWDocumentCapture().processByUsingCamera()

This will perform a document capture using Optical Character Recognition (OCR).

To perform a RFID scan automatically, if it's available, there is an optional enum value available to set while instantiating the AwDocumentCapture() object.

AWDocumentCapture(
  performICAO: ICAO.none
)

ICAO.none is the default value and does not perform RFID scan even if a chip is available.

ICAO.ifAvailable performs a RFID scan only if the document has a RFID chip.

ICAO.required will only successfully capture if the document has a RFID chip

To retrieve the result of the OCR &/or RFID scan the function returnEncryptedString(encyptedString) that triggers at the end of the document capture needs to be created.

 AWDocumentCapture _awDocumentCapture = AWDocumentCapture(
    returnEncryptedString: (encryptedString) {
      log(encryptedString);
    },
 )

In our example above the encrypted string is logged to the console.

Optional fields

There are a few optional fields that can be set to change the behaviour of the Document Capture Package:

  • checkHologram = false,
  • doublePageSpread = false,
  • multiPageProcessing = true,
  • scenarioIdentifier = ScenarioIdentifier.SCENARIO_FULL_PROCESS,
CONTENTS