mrzflutterplugin 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 80

mrzflutterplugin #

MRZ Scanner flutter plugin

Getting Started #

Import the plugin #

Add the following dependancy to pubspec.yaml: mrzflutterplugin: ^1.0.2

In your main.dart import the plugin: import 'package:mrzflutterplugin/mrzflutterplugin.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>

Usage #

Please refer to the example project for usage example.

1.0.2 #

  • Bug fixes

1.0.1 #

  • Bug fixes

1.0.0 #

  • Partial view scanning
  • Continuous scanning
  • Vibrate on successful scan
  • Bugfixes and stability improvements

0.1.3 #

Added method "captureIdImage" that can be used for capturing images of IDs. *This feature is still in beta.

0.1.2 #

Result images exposed in the result as base64 string. "portrait", "signature" and "full_image" (for passports only)

0.1.1 #

Initial release

example/main.dart

import 'dart:async';
import 'dart:convert';
import 'dart:io' show Platform;

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:mrzflutterplugin/mrzflutterplugin.dart';

void main() {
  runApp(new MaterialApp(home: new MyPage()));
}

class MyPage extends StatefulWidget {
  @override
  _MyPageState createState() => new _MyPageState();
}

class _MyPageState extends State<MyPage> {
  String _result = 'No result yet';
  String fullImage;

  @override
  void initState() {
    super.initState();

    if (Platform.isAndroid) {
      Mrzflutterplugin.registerWithLicenceKey("android_licence_key");
    } else if (Platform.isIOS) {
      Mrzflutterplugin.registerWithLicenceKey("ios_licence_key");
    }
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> startScanning() async {
    String scannerResult;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      Mrzflutterplugin.setIDActive(true);
      Mrzflutterplugin.setPassportActive(true);
      Mrzflutterplugin.setVisaActive(true);
      Mrzflutterplugin.setVibrateOnSuccessfulScan(true);

      String jsonResultString = await Mrzflutterplugin.startScanner;

      Map<String, dynamic> jsonResult = jsonDecode(jsonResultString);
      fullImage = jsonResult['full_image'];

      scannerResult = jsonResult['document_number'] +
          ' ' +
          jsonResult['given_names_readable'] +
          ' ' +
          jsonResult['surname'];
    } on PlatformException catch (ex) {
      String message = ex.message;
      scannerResult = 'Scanning failed: $message';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _result = scannerResult;
    });
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future startContinuousScanning(BuildContext context) async {
    Mrzflutterplugin.setIDActive(true);
    Mrzflutterplugin.setPassportActive(true);
    Mrzflutterplugin.setVisaActive(true);
    Mrzflutterplugin.setVibrateOnSuccessfulScan(true);

    MRZScannerCallback callback = (result) {
      if (!result.startsWith("Error")) {
        Map<String, dynamic> jsonResult = jsonDecode(result);
        fullImage = jsonResult['full_image'];

        // If the widget was removed from the tree while the asynchronous platform
        // message was in flight, we want to discard the reply rather than calling
        // setState to update our non-existent appearance.
        if (!mounted) return;

        debugPrint("Successful scan: $result");
      }
    };

    Mrzflutterplugin.startContinuousScanner(callback, true);
  }

  @override
  Widget build(BuildContext buildContext) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            if (fullImage != null) Image.memory(base64Decode(fullImage)),
            new FlatButton(
              child: Text("Start Scanner"),
              onPressed: startScanning,
            ),
            new FlatButton(
              child: Text("Start Continuous Scanner"),
              onPressed: () => startContinuousScanning(context),
            ),
            Padding(
              padding: const EdgeInsets.all(16.0),
              child: Text('Result: $_result'),
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  mrzflutterplugin: ^1.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:mrzflutterplugin/mrzflutterplugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
61
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:mrzflutterplugin/mrzflutterplugin.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:mrzflutterplugin/mrzflutterplugin.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:mrzflutterplugin/mrzflutterplugin.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:mrzflutterplugin/mrzflutterplugin.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • mrzflutterplugin that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

18 out of 18 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/mrzflutterplugin.dart. (-0.50 points)

Analysis of lib/mrzflutterplugin.dart reported 1 hint:

line 25 col 35: This function has a return type of 'Future

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test