1.Adding our Flutter package
To add the mrzscanner_flutter package to your project, you have two options. You can either use the mrzscanner_flutter package from pub.dev or from a local path.
To use the package from pub.dev, add the package name and version to pubspec.yaml:
dependencies:
flutter:
sdk: flutter
mrzscanner_flutter: <package version>
If you prefer to use a local package, download the package from https:/mrzscanner.com and set the package path in pubspec.yaml:
dependencies:
flutter:
sdk: flutter
mrzscanner_flutter: <package version>
path: <package local path>
2.Run flutter pub get command in terminal to install the specified dependencies in your project
3.In your main.dart import the plugin:
import 'package:mrzscanner_flutter/mrzscanner_flutter.dart';
iOS
The MRZScanner plugin requires camera usage so you need to specify the camera usage description in iOS poject's Info.plist
:
<key>NSCameraUsageDescription</key>
<string>Camera is requred for MRZ scanning</string>
Activates the scanner, with a default SCANNER_TYPE_MRZ if not specified.
MrzScanner.startScanner()
Stop and close the scanner.
MrzScanner.closeScanner()
Specify which scanner type you want to use. There are two options: "MRZ Scanner" and "Document Image scanner".
The "MRZ Scanner" option is used to scan for MRZ.
The "Document image scanner" is used for capturing the front and back image of the ID documents.
@param int [ScannerType.MRZ, ScannerType.DOCUMENT_IMAGE_ID, ScannerType.DOCUMENT_IMAGE_PASSPORT, ScannerType.DRIVING_LICENCE, ScannerType.DOCUMENT_IMAGE_ID_FRONT, ScannerType.ID_SESSION]. The default value is ScannerType.MRZ
MrzScanner.setScannerType(ScannerType int)
Resume scanning after the scanner has been paused/stopped. Usually after a successful scan.
MrzScanner.resumeScanning()
@return the currently set date format in which the parsed dates are formatted.
Set the date format in which the parsed dates are formatted.
@param dateFormat the pattern describing the date format. Example: "dd.MM.yyyy"
MrzScanner.setDateFormat(String dateFormat)
@return the current SDK Version.
MrzScanner.getSdkVersion()
Specify whether the scanner should detect and return results for IDs.
@param isIDActive [true, false]. The default value is true.
MrzScanner.setIDActive(isIDActive: Boolean)
Specify whether the scanner should detect and return results for passports.
@param isPassportActive [true, false]. The default value is true.
MrzScanner.setPassportActive(isPassportActive: Boolean)
Specify whether the scanner should detect and return results for visas.
@param isVisaActive [true, false]. Default value is true.
MrzScanner.setVisaActive(isVisaActive: Boolean)
Specify the maximum number of CPU threads that the scanner can use during the scanning process.
@param int [MaxThreads.ONE, MaxThreads.TWO, MaxThreads.THREE, MaxThreads.FOUR, MaxThreads.FIVE,
MaxThreads.SIX]. The default value is MaxThreads.TWO
MrzScanner.setMaxThreads(maxThreads: Int)
Specify the effort level for the scanner to use during the scanning process.
@param int [EffortLevel.CASUAL, EffortLevel.TRY_HARDER, EffortLevel.SWEATY]. The default value is EffortLevel.TRY_HARDER
MrzScanner.setEffortLevel(effortLevel: Int)
Set the zoom factor for the camera preview.
@param double. Default value is 1.0
MrzScanner.setZoomFactor(zoomFactor: Double)
Trigger flashlight.
MrzScanner.toggleFlash(active : Boolean)
Trigger an image picker.
MrzScanner.scanFromGallery()
Returns a base64 string of the scanned id image.
MrzScanner.capturedIdImage()
Register with the license key provided to remove the asterisks (*) from the result.
@param key the provided license key.
@return 0 for success, -1 if registration failed.
MrzScanner.registerWithLicenceKey(key: String)
Customize the overlay of the finder in the scanner
@param base64String takes a base64 type string
MrzScanner.startScannerWithCustomOverlay(base64String : String)
Initiates the scanner view with continuous scanning enabled.
After a successful scan, the scanner will not be dismissed or paused.
To close the scanner call closeScanner().
Ignores duplicate is used to specify whether the scanner should ignore *the successful scan if the document number is identical to the previous *successful scan.
MrzScanner.startContinuousScanner(callback :MRZScannerCallback, ignoreDuplicates : Bool)
Enables vibrate on a successful scan option.
@param boolean: activate.
MrzScanner.setVibrateOnSuccessfulScan(active : Boolean)
Enable automatically extracting portrait image on successful scan; Default value: false.
@param:activated.
MrzScanner.setExtractPortraitEnabled(activated);
Enable automatically extracting signature image on successful scan; Default value: false.
@param:activated.
MrzScanner.setExtractSignatureEnabled(activated);
Enable automatically extracting passport image on successful scan; Default value: false.
@param:activated.
MrzScanner.setExtractFullPassportImageEnabled(activated);
Enable automatically extracting ID(back) image on successful scan; Default value: false.
@param:activated.
MrzScanner.setExtractIdBackImageEnabled(activated);
Set the scanning rectangle to limit the scanning area.The parameters' values are representing percentages of the scanning preview.
@param x the top-left point of the scanning rectangle. [0,...,100]Default value: 5.
@param y the top-left point of the scanning rectangle. [0,...,100]Default value: 20.
@param width the width of the scanning rectangle. [0,...,100]Default value: 90.
@param height the height of the scanning rectangle. [0,...,100]Default value: 60.
MrzScanner.startPartialViewScanner(Int : x, Int : y, Int : width, Int : height)