Skip to main content
Version: Next

Quickstart (Flutter)

Prerequisites

  • License key: Get a trial or production key from the Microblink Developer Hub. Keys are bound to Android's Application ID, and iOS's Bundle Identifier.

Flutter requirements

  • Flutter version: 3.29 and newer

iOS requirements

  • iOS version: 16.0 and newer

Android requirements

  • Minimum SDK: Android 7.0 (API 24)
  • Kotlin version: 2.1.20
  • Android Gradle Plugin: Requires AGP 8.0+

Fast track: try the example app

You can try the SDK by cloning the blinkcard-flutter repository and running the BlinkCard example app.

From the repo root, execute the example app script:

git clone https://github.com/BlinkCard/blinkcard-flutter.git
cd blinkcard-flutter
./initBlinkCardFlutterSample.sh

If you haven't enabled Swift Package Manager support for Flutter, this needs to be done prior to running the application as the BlinkCard iOS package is distributed this way. Run the following command:

flutter config --enable-swift-package-manager

After the script has finished executing, go to the sample folder and run it via Flutter:

cd sample
flutter run

Note: the plugin can be run directly via Xcode (iOS) and Android Studio (Android):

iOS: Open the Runner.xcodeproj in the path: sample/ios/Runner.xcodeproj to run the iOS sample application.

Android: Open the android folder via Android Studio in the sample folder to run the Android sample application.

Example application use-cases

The example application demonstrates how the BlinkCard plugin is implemented, used and shows how to obtain the scanned results. It contains the implementation for:

  • The default implementation with the default BlinkCard UX scanning experience.
  • Multiside DirectAPI scanning - extracting the document information from multiple static images (from the gallery).
  • Singleside DirectAPI scanning - extracting the document information from a single static images (from the gallery).

Install the SDK

  1. To add the BlinkCard plugin to a Flutter project, first create empty project if needed:
flutter create project_name
  1. Since the native BlinkCard iOS SDK is only distributed via Swift Package Manager, Flutter's Swift Package Manager support also needs to be enabled:
flutter config --enable-swift-package-manager
  1. Add the blinkcard_flutter dependency to your pubspec.yaml file:
dependencies:
...
blinkcard_flutter:
  1. Run the command to install the dependency:
flutter pub get

Initialize and scan

Import and create

  1. Import the blinkcard_flutter package:
import 'package:blinkcard_flutter/blinkcard_flutter.dart';
  1. Initialize the BlinkCard plugin:
/// Initialize the plugin
final blinkCardPlugin = BlinkCardFlutter();
  1. Create the BlinkCardSdkSettings object, and pass the license key:
/// set the license key
late String blinkCardLicenseKey;

if (Platform.isAndroid) {
blinkCardLicenseKey = "android-license-key";
} else if (Platform.isIOS) {
blinkCardLicenseKey = "ios-license-key";
}
final sdkSettings = BlinkCardSdkSettings(licenseKey: blinkCardLicenseKey);
sdkSettings.downloadResources = true;

You can get the license key on our Developer Hub account.

  1. Pass the neccessary SDK settings:
/// this was done in step 3.
final sdkSettings = BlinkCardSdkSettings(licenseKey: blinkCardLicenseKey);
sdkSettings.downloadResources = true;

/// Create and modify the Session Settings
final sessionSettings = BlinkCardSessionSettings();

/// Create and modify the scanning settings
final scanningSettings = ScanningSettings();
scanningSettings.skipImagesWithBlur = true;
scanningSettings.tiltDetectionLevel = DetectionLevel.mid;

/// Create and modify the liveness settings
final livenessSettings = LivenessSettings();
livenessSettings.enableCardHelpInHandCheck = true;
livenessSettings.photocopyCheckStrictnessLevel = StrictnessLevel.level5;

/// Create and modify the extraction settings
final extractionSettings = ExtractionSettings();
extractionSettings.extractCardholderName = true;
extractionSettings.extractCvv = true;
extractionSettings.extractInvalidCardNumber = false;

/// Create and modify the anonymization settings
final anonymizationSettings = AnonymizationSettings();
anonymizationSettings.cardHolderNameAnonymizationMode = AnonymizationMode.imageOnly;
anonymizationSettings.cvvAnonymizationMode = AnonymizationMode.fullResult;
anonymizationSettings.cardNumberAnonymizationSettings = CardNumberAnonymizationSettings(
prefixDigitsVisible: 1,
suffixDigitsVisible: 2,
);

/// Create and modify the cropped image settings
final croppedImageSettings = CroppedImageSettings();
croppedImageSettings.returnCardImage = true;

/// Place the above defined settings in the Scanning settings
scanningSettings.extractionSettings = extractionSettings;
scanningSettings.livenessSettings = livenessSettings;
scanningSettings.anonymizationSettings = anonymizationSettings;
scanningSettings.croppedImageSettings = croppedImageSettings;

/// Place the Scanning settings in the Session settings
sessionSettings.scanningSettings = scanningSettings;

/// Create and modify the UX settings
/// This paramater is optional
final scanningUxSettings = ScanningUxSettings();
scanningUxSettings.showHelpButton = true;
scanningUxSettings.showIntroductionAlert = false;
scanningUxSettings.preferredCameraPosition = CameraPosition.back;
scanningUxSettings.allowHapticFeedback = true;
  1. Call the appropriate scanning method (with the default UX, or DirectAPI for static images), handle the results and catch any errors:
// Call the performScan method, where the SDK and session settings need to be passed
// Here, you can also pass the optional ScanningUX object from step 4.
final blinkCardResult = await blinkCardPlugin.performScan(
blinkCardSdkSettings: sdkSettings,
blinkCardSessionSettings: sessionSettings,
scanningUxSettings: scanningUxSettings,
);

print("${blinkCardResult.cardholderName}")

DirectAPI implementation

For the DirectAPI (static image upload) implementation, see the example application here.

Additional documentation

  • Additional documentation for BlinkCard Flutter can be found in the README file on the official GitHub repository here.
  • The API documentation (methods, settings, results) can also be seen in the pub.dev documentation here.