Skip to main content

Initializing the Flutter Barcode Scanner SDK

License key

To run the Scanbot SDK within your production app, you must purchase and use a valid Scanbot SDK license.

Each license key is valid only for a given app bundle identifier. You will be unable to use any of the SDK features if the license key is corrupted, expired, or invalid in any other way.

Example code for initialization with a license:

import 'package:barcode_scanner/scanbot_barcode_sdk.dart';

class MyApp extends StatefulWidget {

_MyAppState createState() {
// Please note: this is just an example license key string (it is not a valid license)
String licenseKey =
"fXbN2PmyqEAZ+btdkSIS36TuX2j/EE5qxVNcZMXYErbLQ" +
"3OBnE10aOQxYI8L4UKwHiZ63jthvoFwUevttctBk0wVJ7Z" +
"+Psz3/Ry8w7pXvfpB1o+JrnzGGcfwBnRi/5raQ2THDeokR" +
"RB1keky2VBOFYbCfYt3Hqms5txF2z70PE/SBTMTIVuxL7q" +
"1xcHDHclbEBriDtrHw8Pmhh9FqTg/r/4kRN/oEX37QGp+Y" +
"3ogwIBbSmV+Cv+VuwtI31uXY3/GkyN/pSJZspIl+exwQDv" +
"O0O1/R/oAURpfM4ydaWReRJtjW8+b1r9rUgPERguaXfcse" +
"HlnclItgDfBHzUUFJJU/g==\nU2NhbmJvdFNESwppby5zY" +
"2FuYm90LmRlbW8ueGFtYXJpbgoxNDg0NjExMTk5CjcxNjc" +
"KMw==\n";
var config = SdkConfiguration(
licenseKey: licenseKey,
loggingEnabled: true
);
await ScanbotBarcodeSdk.initialize(config);
});
return _MyAppState();
}
}

Getting a trial license

The Scanbot SDK will run without a license for one minute per session.

To get a free 7-day trial license, please submit the trial license form.

Please note that a trial license may only be used in a development and staging environment. You are not allowed to publish your app to the App Store, Play Store, or any third-party app store with a trial license.

Purchasing a production license

To get pricing information and purchase a production license for the Scanbot SDK, please request a quote.

App identifier

Every app has a unique identifier (also known as "bundle identifier" or "application ID"). Your license will be bound to this identifier.

To request a trial license or purchase a production license, you need to provide the app identifier of your application.

For Android: Please see the applicationId in the app-level build.gradle file of your android project:

defaultConfig {
...
applicationId "io.scanbot.barcode.example.app.flutter"
}

For iOS: In Xcode see the Bundle Identifier in the "General" settings tab of your project.

Initialization

The Scanbot SDK must be initialized before usage. Make sure to call the initialization after entering the main widget creation.

To initialize the SDK, add the following code snippet:

import 'package:barcode_scanner/scanbot_barcode_sdk.dart';

var config = SdkConfiguration(
licenseKey: "<YOUR_SCANBOT_SDK_LICENSE_KEY>",
);

await ScanbotBarcodeSdk.initialize(config);

The following configuration options can be passed on initialization:

  • licenseKey: Your license key for the Scanbot SDK.
  • loggingEnabled: Optional logging flag. While it may be useful for development, consider disabling logging in production builds for security and performance reasons.
  • storageBaseDirectory: Optional parameter for overriding the default storage directory as a file URI of the Scanbot SDK.
  • enableNativeLogging: Optional boolean flag that enables Scanbot SDK Core native logging (default is false, Android only).
  • fileEncryptionPassword: A secure password or passphrase to derive the AES key for encryption/decryption.
  • fileEncryptionMode: Length of the key in AES encryption - 128 or 256 bits.
  • performanceHintApi: Optional flag that improves performance by making greater use of the top CPU cores (Android only), but also increases battery consumption.
  • allowGpuAcceleration: Optional flag to enable GPU acceleration for TensorFlow ML models (Android only). Default is true. If set to false, GPU acceleration will be disabled for barcode scanning.
  • allowXnnpackAcceleration: Optional flag that controls whether XNN pack optimizations should be used (Android only). Default is true.

Logging

When initializing the Scanbot SDK, you have the option to enable logging. By default, logging is disabled.

import 'package:barcode_scanner/scanbot_barcode_sdk.dart';

var config = SdkConfiguration(
licenseKey: "",
loggingEnabled: true,
// ...
);
await ScanbotBarcodeSdk.initialize(config);

On Android, logs are printed into LogCat and saved on the device. You can find them in Environment.getExternalStorageDirectory()/debug_logs/[package_name] (usually /sdcard/debug_logs/[package_name]).

The easiest way to check the log outputs on Android is to use the Android Debug Bridge (adb) (e.g., $ adb -s <DEVICE_ID> shell "logcat").

On iOS, all logs are printed to the console. Please use Xcode to check the log outputs.

warning

While it is useful for development, we recommend disabling logging in production builds for security and performance reasons.

Want to scan longer than one minute?

Generate a free trial license to test the Scanbot SDK thoroughly.

Get free trial license