Genius Scan SDK for Flutter

Description

The Genius Scan SDK for Flutter enables you to integrate the document scanning experience that powers the Genius Scan app in your Flutter app.

It offers a component enabling you to implement the Genius Scan SDK Scan Flow, an all-in-one configurable scanner module with the following key features:

  • Automatic document detection
  • Document perspective correction
  • Image enhancement with 4 different modes (Black & white, Monochrome, Color, Photo)
  • Batch scanning of several pages in row
  • OCR to extract raw text from images and generate PDF with invisible text layer

License

You can try the "demo" version for free without a license key, the only limitation being that the app will stop working after 60 seconds.

You need to set a license key for unlimited demo time, or for production.

To buy a license:

  1. Sign up to our developer console
  2. Submit a quote request for each application

You can learn more about licensing in our website and contact us at sales@geniusscansdk.com for further questions.

Getting started

Follow the install steps from https://pub.dev/packages/flutter_genius_scan/install

Additional steps on Android

  • To your app android/app/build.gradle, change minSdkVersion to 23.

Additional steps on iOS

  • Add the required permission to your Info.plist:
NSCameraUsageDescription - "We use the camera for <provide a good reason why you are using the camera>"
  • In your Podfile, add the following line:
platform :ios, '15.0'

Usage

Set the license key

Initialize the SDK with a valid license key:

FlutterGeniusScan.setLicenseKey('REPLACE_WITH_YOUR_LICENSE_KEY');

This method doesn't return anything. However, other methods of the plugin will fail if the license key is invalid or expired. Note that, for testing purpose, you can also use the plugin without setting a license key, but it will only work for 60 seconds.

It is recommended to show a message to users asking them to update the application in case the license has expired.

Start the scanner module

var result = await FlutterGeniusScan.scanWithConfiguration(configuration);

See the API doc for the options supported in the configuration object and for the result structure.

(Optional) Generate a PDF document from multiple pages

If you'd like to rearrange the pages returned by the ScanFlow or add some more pages, you can do so and generate a PDF document from these pages:

await FlutterGeniusScan.generateDocument(configuration)

See the API doc for the options supported in the configuration object.

Error handling

Errors are returned as a PlatformException with a structured payload in details:

  • code: standardized error code
  • message: developer-facing diagnostic message
  • recovery_message: developer-facing recovery suggestion (may be empty)
  • underlying_error: stringified underlying error (may be empty)

The code field is one of:

Code Description Suggested handling
cancellation_error The user canceled the document or barcode scan flow. Treat as a normal exit; do not show an error.
configuration_error The configuration or input parameters are invalid. Fix the configuration before retrying.
licensing_error The license key is invalid, expired, or not initialized. Verify the license key and contact support if needed.
capture_error The camera or capture session failed. Let the user retry; restart the device if the problem persists.
storage_space_error There is not enough storage space to write generated files. Ask the user to free up storage space and retry.
internal_error An unexpected SDK error occurred. Show a generic error and collect underlying_error for diagnostics.

message and recovery_message are English diagnostics for developers. They are not intended to be displayed directly to end users; use code to choose your own localized user-facing message.

Example:

try {
  await FlutterGeniusScan.scanWithConfiguration(configuration);
} on PlatformException catch (error) {
  final details = Map<String, String>.from(error.details as Map);
  print(details["code"]);
  print(details["message"]);
  print(details["recovery_message"]);
  print(details["underlying_error"]);
}

FAQ

How do I get the UI translated to another language?

The device's locale determines the languages used by the plugin for all strings: user guidance, menus, dialogs…

The plugin supports a wide variety of languages: English (default), Arabic, Chinese (Simplified), Chinese (Traditional), Danish, Dutch, French, German, Hebrew, Indonesian, Italian, Japanese, Korean, Portuguese, Russian, Spanish, Swedish, Turkish, Vietnamese.

NB: iOS applications must be localized in XCode by adding each language to the project.

What should I do if my license is invalid?

Make sure that the license key is correct, that is has not expired, and that it is used with the App ID it was generated for. To learn more about the procurement and replacement of license keys, refer to the Licensing FAQ.

Troubleshooting

Refer to the troubleshooting guides of the native libraries to resolve common configuration and build problems: