fluttervisionsdkplugin 0.3.0 fluttervisionsdkplugin: ^0.3.0 copied to clipboard
A Flutter plugin package for integrating the Flutter Vision SDK into your Flutter application for scanning Barcodes and QrCodes
Flutter Vision SDK Plugin #
A Flutter plugin package for seamless integration of the Flutter Vision SDK into your Flutter applications. This package provides features for scanning barcodes, QR codes, and text, along with OCR (Optical Character Recognition) support. Customize scan and capture modes to meet your specific needs.
Features #
Scan barcodes, QR codes, and text. Optical Character Recognition (OCR) support. Flexible customization of scan and capture modes.
Getting started #
import the package and use it in your app.
import 'package:fluttervisionsdkplugin/fluttervisionsdkplugin.dart';
Usage #
Here's an example of how to use the NativeViewWidget in your Flutter application:
class VisionSDKView extends StatefulWidget {
const VisionSDKView({super.key});
@override
State<VisionSDKView> createState() => VisionSDKState();
}
class VisionSDKState extends State<VisionSDKView> {
MyPluginToFlutterCommunicator receiver = MyPluginToFlutterCommunicator();
FlutterToPluginCommunicator? sender;
@override
Widget build(BuildContext context) {
return VisionCameraWidget(
environment: Environment.sandbox,
listener: receiver,
onViewCreated: (FlutterToPluginCommunicator sender) {
this.sender = sender;
this.sender?.startCamera();
},
);
}
}
class MyPluginToFlutterCommunicator extends PluginToFlutterCommunicator {
@override void onCameraStarted() {}
@override void onCameraStopped() {}
@override void onScanError(String error) {}
@override void onCodesReceived(List<String> codes) {}
@override void onDetectionResult(bool isText, bool isBarcode, bool isQrCode) {}
@override void onImageCaptured(String base64Image, List<String> codes) {}
@override void onOnDeviceConfigureProgress(double progress) {}
@override void onOnDeviceConfigurationComplete() {}
@override void onOnlineSLResult(Map<String, dynamic> result) {}
@override void onOnlineBOLResult(Map<String, dynamic> result) {}
@override void onOnDeviceOCRResult(Map<String, dynamic> result) {}
}
User can set capture modes to Barcode, QRCode or OCR as following:
void setCaptureMode(FlutterToPluginCommunicator? sender) {
sender?.setCaptureModeBarcode();
// OR
sender?.setCaptureModeQrCode();
// OR
sender?.setCaptureModeOCR();
}
User can set scan modes to Auto or Manual as following:
void setCaptureMode(FlutterToPluginCommunicator? sender) {
sender?.setScanMode(1); // Auto
// OR
sender?.setScanMode(2); // Manual
}
In order to detect Barcode or QRCode in Manual mode, use the following function:
void capture(FlutterToPluginCommunicator? sender) {
sender?.capturePhoto();
}
// You will get results in the following callback:
@override void onCodesReceived(List<String> codes) {
print(codes);
}
In order to perform OCR processes in Manual mode, use the following function:
void capture(FlutterToPluginCommunicator? sender) {
sender?.capturePhoto();
}
// You will get the captured image in Base64 format and any barcodes detected in that image in the following callback:
@override void onImageCaptured(String base64Image, List<String> codes) {
}
Shipping Label API #
After an image is captured, you can send it to our cloud service for further logistics processing like extracting data from a shipping label. You can do that using the following methods:
void makeShippingLabelAPICall(FlutterToPluginCommunicator? sender, String base64Image, List<String> codes) {
sender?.callOcrApi(
apiKey: 'YOUR_API_KEY_HERE',
// OR
token: 'YOUR_TOKEN_HERE',
image: base64Image,
barcodes: codes
);
}
// You will get the response from API in following functions:
@override void onOnlineSLResult(Map<String, dynamic> result) {
}
// Or in case of any error:
@override void onScanError(String error) {
}
Bill of Lading API #
After an image is captured, you can send it to our cloud service for further logistics processing like extracting data from a bill of lading. You can do that using the following methods:
void makeBillOfLadingAPICall(FlutterToPluginCommunicator? sender, String base64Image, List<String> codes) {
sender?.callBolApi(
apiKey: 'YOUR_API_KEY_HERE',
// OR
token: 'YOUR_TOKEN_HERE',
image: base64Image,
barcodes: codes);
}
// You will get the response from API in following functions:
@override void onOnlineBOLResult(Map<String, dynamic> result) {
}
// Or in case of any error:
@override void onScanError(String error) {
}
On-Device Shipping Label #
After an image is captured, you can extract shipping label information from it using our On-Device image processing AI powered capabilities, without the requirement of Internet. In order to do that, firstly you need to call the following function to load the AI related files before image processing actually begins:
void configureOnDeviceSLModel(FlutterToPluginCommunicator? sender) {
sender?.configureOnDeviceOCR(
apiKey: 'YOUR_API_KEY_HERE',
// OR
token: 'YOUR_TOKEN_HERE',
modelClass: ModelClass.shippingLabel,
modelSize: ModelSize.large);
}
Note that currently only
ModelClass.shippingLabel
is supported and onlyModelSize.micro
orModel.large
are available.
You will get its progress and completion callbacks in the following function:
@override void onOnDeviceConfigureProgress(double progress) {
// Progress goes from 0.0 to 1.0
}
@override void onOnDeviceConfigurationComplete() {
// At this point, model configuration has been completed.
}
// Or in case of any error:
@override void onScanError(String error) {
}
After model configuration has been completed, you can send the Base64
image to the following function to extract Shipping Label information from it:
void getShippingLabelInfoOffline(FlutterToPluginCommunicator? sender, String base64Image, List<String> codes) {
sender?.getPredictions(base64Image, codes);
}
// You will get the response in following functions:
@override void onOnDeviceOCRResult(Map<String, dynamic> result) {
}
// Or in case of any error:
@override void onScanError(String error) {
}
Native Doccumentation #
iOS Documentation #
- To see the iOS documentation you can visit here to see the details of each feature and their configuration parameters
Android Documentation #
- To see the Android documentation you can visit here to see the details of each feature and their configuration parameters
Additional information #
Users can import this package and integrate it into their Flutter projects to enable barcode and QR code scanning with customizable modes. This package provides a simple and efficient way to leverage the power of the Flutter Vision SDK in your applications.
For ios installation you need to install the pods
again
For android add the below code in setting.gradle:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
}
Add the below line in android->build.gradle->
inside repositories
and all projects
.
maven { url "https://jitpack.io" }
Set the below versions
minSdkVersion 29
targetSdkVersion 34
in android->app->build.gradle.