BlinkCard Flutter plugin
The BlinkCard SDK is a comprehensive solution for implementing secure card scanning on Flutter. It offers powerful capabilities for capturing and analyzing a wide range of payment cards. The package consists of BlinkCard, which serves as the core module, and the BlinkCardUX package that provides a complete, ready-to-use solution with a user-friendly interface.
Please note that, for maximum performance and full access to all features, it’s best to go with one of our native SDKs (for iOS or Android).
However, since the wrapper is open source, you can add the features you need on your own.
Current release: 3001.0.0 (native Android & iOS SDK 3001.0.0). Upgrading from 3000.x? See Release notes.
Table of contents
- Licensing
- Requirements
- Quickstart with the sample application
- Plugin integration
- Plugin usage
- Plugin specifics
- pub.dev
- Additional information
Licensing
A valid license key is required to initialize the BlinkCard plugin. A free trial license key can be requested after registering at the Microblink Developer Hub.
Requirements
| Requirement | Flutter | iOS | Android |
|---|---|---|---|
| OS/API version | Flutter 3.29 and newer | iOS 16.0 and newer | API version 24 and newer |
| Camera quality | - | At least 1080p | At least 1080p |
Android host application (SDK 3001):
-
compileSdk36 and Android Gradle Plugin 8.9.1 or newer -
Kotlin 2.1 or newer to compile against the plugin (the plugin library is built with Kotlin 2.2.21)
-
For additional help with the Flutter setup, view the official documentation.
-
For more detailed information about the BlinkCard Android and iOS requirements, view the native SDK documentation here (Android & iOS).
Quickstart with the sample application
The sample 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).
To obtain and run the sample application, follow the steps below:
- Git clone the repository:
git clone https://github.com/microblink/blinkcard-flutter.git
- Position to the obtained BlinkCard folder and run the
initBlinkCardFlutterSample.shscript:
cd blinkCard-flutter && ./initBlinkCardFlutterSample.sh
- After the script finishes running, position to the
samplefolder and run theflutter runcommand:
cd sample && flutter run
- Pick the platform to run the BlinkCard plugin on.
Note: the plugin can be run directly via Xcode (iOS) and Android Studio (Android):
- Open the
Runner.xcodeprojin the path:sample/ios/Runner.xcodeprojto run the iOS sample application. - Open the
androidfolder via Android Studio in thesamplefolder to run the Android sample application.
Sample app on iOS additional instructions
- Error:
Module 'blinkcard-flutter' not found
If you are getting the error above when running the sample application, this usually means that support for Swift Package Manager was not enabled in the Flutter configuration. Simply run the following command to enable it:
flutter config --enable-swift-package-manager
After this, try to run the sample application again.
- Error:
FlutterGeneratedPluginSwiftPackage has a lower minimum deployment targetorblinkcard-flutter-productrequires iOS 16.0 but the target supports 15.0 (or lower)
BlinkCard requires iOS 16.0+. The host app’s deployment target must be at least 16.0 so FlutterGeneratedPluginSwiftPackage can match the plugin’s Swift package minimum version.
- Exit Xcode
- Set the iOS deployment target to 16.0 (Xcode: Runner → General → Minimum Deployments, or set
IPHONEOS_DEPLOYMENT_TARGET = 16.0inios/Runner.xcodeproj/project.pbxproj) - Regenerate iOS config:
flutter build ios --config-only
- Run the sample application again
Plugin integration
- To add the BlinkCard plugin to a Flutter project, first create empty project if needed:
flutter create project_name
- 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
- Add the blinkcard_flutter dependency to your
pubspec.yamlfile:
dependencies:
...
blinkcard_flutter:
- Run the command to install the dependency:
flutter pub get
- iOS only: set the app’s minimum iOS version to 16.0 (BlinkCard native SDK requirement). In Xcode, set Runner’s Minimum Deployments to iOS 16.0, then run:
flutter build ios --config-only
Plugin usage
Minimal plugin example
/// import the blinkcard_flutter package
import 'package:blinkcard_flutter/blinkcard_flutter.dart';
/// set the license key
late String blinkCardLicenseKey;
if (Platform.isAndroid) {
blinkCardLicenseKey = "android-license-key";
} else if (Platform.isIOS) {
blinkCardLicenseKey = "ios-license-key";
}
/// Initialize the plugin
final blinkCardPlugin = BlinkCardFlutter();
/// Add the license key
/// Call the `performScan` method
/// Get the results
Future<void> performScan() async {
final blinkCardResult = await blinkCardPlugin.performScan(
blinkCardSdkSettings: BlinkCardSdkSettings(
licenseKey: "your-license-key",
),
blinkCardSessionSettings: BlinkCardSessionSettings(),
);
print(blinkCardResult?.cardholderName);
}
Advanced plugin example
- After the dependency has been added to the project, first add the necessary import:
import 'package:blinkcard_flutter/blinkcard_flutter.dart';
- Initialize the BlinkCard plugin:
final blinkCardPlugin = BlinkCardFlutter();
- Set all of the necessary BlinkCard settings (SDK settings, session settings, and the scanning settings). If the mentioned settings are not modified, the default values will be used:
// Add the license key for each platform
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;
/// Create and modify the Session Settings
final sessionSettings = BlinkCardSessionSettings();
/// Create and modify the scanning settings
final scanningSettings = ScanningSettings();
scanningSettings.skipImagesWithBlur = true;
scanningSettings.tiltSensitivityLevel = SensitivityLevel.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 redaction settings (optional).
/// If omitted, native SDK 3001 redaction defaults apply (PAN/CVV redacted;
/// four prefix and four suffix digits visible on the card number).
final redactionSettings = RedactionSettings();
redactionSettings.cardholderNameRedactionMode = RedactionMode.none;
redactionSettings.cvvRedactionMode = RedactionMode.fullResult;
redactionSettings.cardNumberRedactionSettings = CardNumberRedactionSettings(
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.redactionSettings = redactionSettings;
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;
scanningUxSettings.allowScanSound = true;
- 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 3.
final blinkCardResult = await blinkCardPlugin.performScan(
blinkCardSdkSettings: sdkSettings,
blinkCardSessionSettings: sessionSettings,
scanningUxSettings: scanningUxSettings,
);
- The whole integration process can be found in the sample app
main.dartfile here. - The settings and the results that can be used with the BlinkCard plugin can be found in the paragraphs below, but also in the comments of each BlinkCard Dart file.
Plugin specifics
The BlinkCard plugin implementation is located in the lib folder, while platform-specific implementation is located in the android and ios folders.
Scanning methods
Currently, the BlinkCard plugin contains the following methods: performScan and performDirectApiScan.
The performScan method
The performScan method launches the BlinkCard scanning process with the default UX properties.
It takes the following parameters:
- BlinkCard SDK settings
- BlinkCard Session settings
- The optional BlinkCard scanning UX settings
BlinkCard SDK Settings - BlinkCardSdkSettings: the class that contains all of the available SDK settings. It contains settings for the license key, and how the models (that the SDK needs for the scanning process) should be obtained.
BlinkCard Session Settings - BlinkCardSessionSettings: the class that contains specific scanning configurations that define how the scanning session should behave.
BlinkCard Scanning UX settings - ScanningUxSettings - the optional class that allows customization of various aspects of the UI used during the scanning process.
- The implementation of the
performScanmethod can be viewed here in the blinkcard_flutter_method_channel.dart file.
The performDirectApiScan method
The performDirectApiScan method launches the BlinkCard scanning process intended for information extraction from static images.
It takes the following parameters:
- BlinkCard SDK settings
- BlinkCard Session settings
- The first side image string in the Base64 format
- The optional second side image string in the Base64 format
BlinkCard SDK Settings - BlinkCardSdkSettings: the class that contains all of the available SDK settings. It contains settings for the license key, and how the models (that the SDK needs for the scanning process) should be obtained.
BlinkCard Session Settings - BlinkCardSessionSettings: the class that contains specific scanning configurations that define how the scanning session should behave.
The first image Base64 string - String: image that represents one side of the card.
- This image must contain the card side where the card number (PAN) is located.
- If this side of the card contains all of the neccessary information (e.g. CVV, cardholder name) that were set in the
ExtractionSettings, then no second image is required.
The optional second image Base64 string - String: image that represents one side of the card.
-
Required only if not all information specified in
ExtractionSettingscan be obtained from the first side of the card. -
The implementation of the
performDirectApiScanningmethod can be viewed here in the blinkcard_flutter_method_channel.dart file.
SDK loading & unloading
The BlinkCard SDK also contains methods for loading and unloading. These methods can be called before the scanning methods described above to preload the required resources and reduce the startup time of a scanning session. They can also be used to release resources after the scanning session has finished.
SDK loading
The loadSdk method creates or retrieves the instance of the BlinkCard SDK. It initializes and loads the BlinkCard SDK if it is not already loaded.
It can be called in advance to preload the SDK before starting a scanning session. Doing so reduces loading time for the performScan and performDirectApiScan methods, since all resources will already be available and the license verified.
If the method is not called beforehand, it will still be automatically invoked on the native platform channels when a scan starts. However, the initial scan may take longer due to resource loading and license checks.
It takes the following parameter: BlinkCardSdkSettings, which is explained in more details below.
SDK unloading
The unloadSdk platform method terminates the BlinkCard SDK and releases all associated resources. It safely shuts down the SDK instance and frees any allocated memory.
After calling this method, you must reinitialize the SDK (by calling loadSdk or any of the scanning methods) before using it again.
It takes the following parameter: deleteCachedResources.
- If set to
true(falseis default), the method performs a complete cleanup, including deletion of all downloaded and cached SDK resources from the device.
This method is automatically called after each successful scan session.
BlinkCard Settings
The BlinkCard SDK contains various settings, modifying different parts of scanning process:
- BlinkCard SDK settings
- BlinkCard Session settings
- Scanning settings
- Liveness settings
- Extraction settings
- Redaction settings
- Cropped image settings
- Scanning UX settings
-
BlinkCard SDK settings -
BlinkCardSdkSettings
These settings are used for the initialization of the BlinkCard SDK. It contains settings for the license key, and how the models (that the SDK needs for the scanning process) should be obtained. OptionalresourceRequestTimeout(milliseconds) controls resource download timeouts on both platforms (native default 30 seconds in SDK 3001). -
BlinkCard Session settings -
BlinkCardSessionSettings
These settings represent the configuration settings for a scanning session.
The class that contains specific scanning configurations that define how the scanning session should behave, includingstepTimeTimeoutInterval(milliseconds, default 60 seconds) andinactivityTimeoutInterval(milliseconds, default 10 seconds;0disables inactivity timeout). -
Scanning settings -
ScanningSettings
These settings represent the configurable settings for scanning a card.
This class defines various parameters and policies related to the scanning process, including image quality handling, data extraction, redaction, and liveness detection, along with options for frame processing and image extraction. -
Liveness settings -
LivenessSettings
Settings for liveness detection during card scanning.
This class defines various parameters that control the behavior of liveness detection, including thresholds for hand detection, screen and photocopy analysis, and options to skip processing certain frames based on liveness criteria. -
Extraction settings -
ExtractionSettings
Settings that control which fields and images should be extracted from the payment card.
Disabling extraction of unused fields can improve recognition performance or reduce memory usage. -
Redaction settings -
RedactionSettings
Optional onScanningSettings. When omitted, native SDK redaction defaults apply. Assign explicitly to override (for exampleRedactionMode.nonefor unredacted fields). -
Cropped image settings -
CroppedImageSettings
These settings represent the image cropping settings.
This class controls how card images are cropped, including the resolution, extension of the cropping area, and whether the cropped image should be returned in the results. -
Scanning UX settings -
ScanningUxSettings
These settings allow customization of various aspects of the UI/UX. Displaying certain UI elements, haptic feedback, scan sounds, along with choosing the preffered camera position used when capturing document can modified.
Additional notes:
-
The blinkcard_settings.dart file contains all the settings that can be modified and explains what each setting does in more detail.
-
The native documentation for the above mentioned settings can be found here for Android & iOS.
-
The native Kotlin & Swift implementation of all BlinkCard settings can be found here for Android & iOS in the BlinkCard deserialization utilities.
BlinkCard Results
The result of the scanning process is stored in the BlinkCardScanningResult. It contains the results of scanning a card, including the extracted data, liveness information, and the card images:
-
Issuing network-
String
Payment card's issuing network. -
Card account result -
List<CardAccountResult>
Payment card accounts found on the card.
A list of payment card accounts found on the card. Each result in the list represents a distinct payment account containing details like the card number, CVV, expiry date, andbinCheckResult(pass,fail, ornotAvailablewhen BIN check runs). -
IBAN -
String?
The IBAN (International Bank Account Number) of the card, or null if not available. -
Cardholder name -
String?
Information about the cardholder name, or null if not available. -
Overall card liveness result -
CheckResult
The overall liveness check result for the card.
This result aggregates the outcomes of various liveness checks performed on the card to determine its authenticity
- Set to
passif all individual checks have passed. - Set to
failif any individual check has failed. - Set to
notAvailablewhen a check was not run (SDK 3001; replaces the formernotPerformedvalue).
Additional notes:
-
The blinkCard_result.dart file contains all the results that can be obtained and explains what each result represents in more detail.
-
The native documentation for the above mentioned results can be found here for Android & iOS.
-
The native Kotlin & Swift implementation of all BlinkCard results can be found here for Android & iOS in the BlinkCard serialization utilities.
pub.dev
- The BlinkCard Flutter package can also be found on pub.dev here.
- The package documentation/API references can be viewed here.
Additional information
For any additional questions and information, feel free to contact us here, or directly to the Support team via mail support@microblink.com.