Skip to main content

Getting started | Flutter Document Scanner

Installation#

The Scanbot SDK Flutter Plugin is available as a Flutter Dart package scanbot_sdk on pub.dev. You can simply add it as a dependency to your app.

Add the scanbot_sdk plugin to your pubspec.yaml file as dependencies:

dependencies:  scanbot_sdk: ^2.1.0  # see the latest sdk version

Use the flutter CLI (or your IDE) to fetch and install the packages:

$ flutter pub get

Android#

In the top-level android/build.gradle file:

  • Update Kotlin version to at least 1.4.0 or higher. Typically defined via ext.kotlin_version variable:
      ...  buildscript {      ext.kotlin_version = '1.4.0'      ...  }

In the app-level android/app/build.gradle file:

  • Add the following packagingOptions

      android {      ...      packagingOptions {          pickFirst 'META-INF/atomicfu.kotlin_module'          pickFirst 'META-INF/proguard/coroutines.pro'          exclude 'META-INF/LICENSE.txt'          exclude 'META-INF/NOTICE.txt'          exclude 'META-INF/LICENSE'          exclude 'META-INF/NOTICE'      }  }
  • Enable multidex:

      android {      defaultConfig {        ...        multiDexEnabled true      }  }

In the android/app/src/main/AndroidManifest.xml file:

  • Add the largeHeap flag: Since your application will work with high-resolution images it is strongly recommended to add the attribute android:largeHeap="true" in the <application> element of your AndroidManifest.xml file, especially for Android <= 7.x. Processing hi-res images is a memory intensive task and this property will ensure your app has enough heap allocated to avoid OutOfMemoryError exceptions.

  • Add the CAMERA permission:

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

iOS#

For iOS you need to adjust the Podfile and install or update the Pods:

Make sure you have specified a global platform version in the ios/Podfile file, like:

platform :ios, '11.0'

Then run:

$ cd ios/$ pod install --repo-update

In your Info.plist file add the required NSCameraUsageDescription property:

NSCameraUsageDescription - "Privacy - Camera Usage Description". Describe why your app wants to access the camera.

Please note that without this property the app will crash on camera access!

Plugin SDK Modules#

  • ScanbotSdk - This module provides the Scanbot SDK functionality for image operations (e.g. filter, PDF creation, etc.)

  • ScanbotSdkUi - Provides the UI functionality like Document Scanner UI, Cropping UI, Barcode Scanner UI, MRZ Scanner UI and EHIC Scanner UI.