IDCheckio Sdk - Flutter plugin

Platform specific configuration

iOS

  1. In your project folder, go to your iOS directory and open the Podfile :
  • Change the minimum version to at least '10.0' on the top of the file
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'
  • Add the following lines above the targetsection :
source 'https://github.com/CocoaPods/Specs.git'
source 'https://git-externe.rennes.ariadnext.com/idcheckio/axt-podspecs.git'
  1. Retrieve the sdk using pod install --repo-update
  • ⚠️⚠️   You will need to have a .netrc file on your $HOME folder setup with our credentials. Check the official documentation for more informations.  ⚠️⚠️
  1. In your project, open the *.plist file and the following entry :
  • "Privacy - Camera Usage Description" : "Camera is being used to scan documents"

Android

  1. Open your build file android/app/build.gradle :- In the android block, add the following lines :
packagingOptions {
    pickFirst 'META-INF/NOTICE'
    pickFirst 'META-INF/LICENSE'
    pickFirst 'META-INF/license.txt'
    pickFirst 'META-INF/notice.txt'
    pickFirst 'META-INF/DEPENDENCIES'
}
  1. In order to access our external nexus for retrieving the latest version of the IDCheck.io SDK, you have to update the gradle file from the plugin project PATH_TO_PLUGIN_FOLDER/android/build.gradle, and replace $YOUR_USERNAME and $YOUR_PASSWORD with the credentials given by our support team.

Usage

  1. Import the following file :
import 'package:idcheckio/idcheckio.dart';
  1. Before capturing any document, you need to activate the licence. you have to use the activate() method with your activation token.
  Future<void> activateSDK() async {
    bool activationStatus = false;
    try {
      await _idcheckioPlugin.activate(
          idToken: _activationToken,
          extractData: true);
      activationStatus = true;
    } on PlatformException catch (e) {
      activationStatus = false;
      ErrorMsg errorMsg = ErrorMsg.fromJson(jsonDecode(e.message!));
      debugPrint("An error happened during the activation : ${errorMsg.cause} - ${errorMsg.details} - ${errorMsg.message}");
    }
    if (!mounted) return;
    setState(() {
      _sdkActivated = activationStatus;
    });
  }
  1. To start the capture of a document, you have to call the start() method with an IdcheckioParams object. You will receive the result in an IdcheckioResult object.
final IDCheckioParams paramsIDOnline = IDCheckioParams(IDCheckioParamsBuilder()
  ..docType = DocumentType.ID
  ..orientation = IDCheckioOrientation.PORTRAIT
  ..integrityCheck = IntegrityCheck(readEmrtd: true, docLiveness: false)
  ..onlineConfig = OnlineConfig(isReferenceDocument: true));

  Future<void> capture() async{
    IDCheckioResult? result;
    try {
      result = await _idcheckioPlugin.start(_selectedItem.params!);
      debugPrint('ID Capture Successful : ${result!.toJson()}', wrapWidth: 500);
    } on PlatformException catch(e) {
      ErrorMsg errorMsg = ErrorMsg.fromJson(jsonDecode(e.message!));
      debugPrint("An error happened during the capture : ${errorMsg.cause} - ${errorMsg.message} - ${errorMsg.subCause}");
    }
    if (!mounted) return;
    setState(() {
      _captureResult = result;
    });
  }
  1. To start an online capture of a document, use the startOnline() method. You will receive the result in an IdcheckioResult object.
  final IDCheckioParams paramsLiveness = IDCheckioParams(
      IDCheckioParamsBuilder()
            ..docType = DocumentType.LIVENESS
            ..orientation = IDCheckioOrientation.PORTRAIT
            ..confirmAbort = true
  );

  Future<void> capture() async{
    IDCheckioResult? result;
    try {
      result = await _idcheckioPlugin.startOnline(_selectedItem.params!, _captureResult?.onlineContext);
      debugPrint('ID Capture Successful : ${result!.toJson()}', wrapWidth: 500);
    } on PlatformException catch(e) {
      ErrorMsg errorMsg = ErrorMsg.fromJson(jsonDecode(e.message!));
      debugPrint("An error happened during the capture : ${errorMsg.cause} - ${errorMsg.message} - ${errorMsg.subCause}");
    }
    if (!mounted) return;
    setState(() {
      _captureResult = result;
    });
  }
  1. If you don't want to capture but just analyze a document, you can use the analyze() method. You will receive the result in an IdcheckioResult object.
Future<void> analyze() async{
    IDCheckioResult? result;
    try {
      ImagePicker imagePicker = ImagePicker();
      inal pickedFile = await (imagePicker.getImage(source: ImageSource.gallery));
      if (pickedFile != null) {
        result = await _idcheckioPlugin.analyze(
          params: _selectedItem.params!,
          side1Uri: pickedFile.path,
          side2uri: null,
          isOnline: true,
          onlineContext: _captureResult?.onlineContext);
      }
      debugPrint('ID Capture Successful : ${result!.toJson()}', wrapWidth: 500);
    } on PlatformException catch(e) {
      ErrorMsg errorMsg = ErrorMsg.fromJson(jsonDecode(e.message!));
      debugPrint("An error happened during the capture : ${errorMsg.cause} - ${errorMsg.message} - ${errorMsg.subCause}");
    }
    if (!mounted) return;
    setState(() {
      _captureResult = result;
    });
  }
  1. If you want to start an ips session, you first need to create a new ips session by following the IPS documentation and then call the startIps method with the retrieved token. The result is empty when the capture is succesful and an error is send otherwise. If you want to retrieve your data you need to check on ips the result of the capture.
  Future<void> startIps() async {
    IDCheckioResult? result;
    try {
      result = await IDCheckio.startIps(ipsController.text);
    } on PlatformException catch (e) {
      ErrorMsg errorMsg = ErrorMsg.fromJson(jsonDecode(e.message!));
      debugPrint("An error happened during the ips session : ${errorMsg.cause} - ${errorMsg.message} - ${errorMsg.subCause}");
    }
    if (!mounted) return;
    setState(() {
      _captureResult = result;
    });
  }

Theming

If you want to change the colors of the sdk to match your theme, it's possible ! You need to first create an IDCheckTheme() object with your own colors and then add it in the builder in the theme parameter.

IDCheckTheme myTheme = IDCheckTheme(primaryColor: Color(0xFF0000B7), borderColor: Color(0xFF0000B7), foregroundColor: Color(0xFFF2F2F2), backgroundColor: Color(0xFFFFFFFF))
IDCheckioParamsBuilder()
  ..theme = myTheme

You're now good to go! ✅
To learn more about those methods and their parameters, please refer to the official IDCheck.io Mobile SDK documentation.