fluttervisionsdkplugin 1.2.1 copy "fluttervisionsdkplugin: ^1.2.1" to clipboard
fluttervisionsdkplugin: ^1.2.1 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/visionsdk.dart';
import 'package:fluttervisionsdkplugin/visioncamerawidget.dart';
import 'package:fluttervisionsdkplugin/ondeviceocrmanager.dart';
copied to clipboard

Usage #

It is important to initialize VisionSDK before accessing any of its other classes. You can initialize VisionSDK by using the following code:

VisionSDK().initialize(Environment.sandbox);
copied to clipboard

Here's an example of how to use the VisionCameraWidget 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
  void initState() {
    super.initState();
    VisionSDK().initialize(Environment.sandbox);
  }

  @override
  Widget build(BuildContext context) {
    return VisionCameraWidget(
      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(Uint8List byteArrayImage, List<String> codes) {}
  @override void onOnlineSLResult(Map<String, dynamic> result) {}
  @override void onOnlineBOLResult(Map<String, dynamic> result) {}
}

class MainOnDeviceOCRManagerListener implements OnDeviceOCRManagerListener {
  @override void onOnDeviceConfigureProgress(double progress) {}
  @override void onOnDeviceConfigurationComplete() {}
  @override void onOnDeviceOCRResult(Map<String, dynamic> result) {}
  @override void onError(String error) {}
  @override void onReportResult(Map<ReportResult, String> reportResult) {}
}
copied to clipboard

User can set capture modes to Barcode, QRCode or OCR as following:

  void setCaptureMode(FlutterToPluginCommunicator? sender) {
    sender?.setCaptureModeBarcode();
    // OR
    sender?.setCaptureModeQrCode();
    // OR
    sender?.setCaptureModeOCR();
  }
copied to clipboard

User can set scan modes to Auto or Manual as following:

  void setCaptureMode(FlutterToPluginCommunicator? sender) {
    sender?.setScanMode(1); // Auto
    // OR
    sender?.setScanMode(2); // Manual
  }

copied to clipboard

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);
  }  
copied to clipboard

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(Uint8List byteArrayImage, List<String> codes) {

  }  
copied to clipboard

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, Uint8List byteArrayImage, List<String> codes) {
    sender?.callShippingLabelApi(
          apiKey: 'YOUR_API_KEY_HERE',
          // OR
          token: 'YOUR_TOKEN_HERE',
          image: byteArrayImage,
          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) {

  }
copied to clipboard

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, Uint8List byteArrayImage, List<String> codes) {
    sender?.callBolApi(
          apiKey: 'YOUR_API_KEY_HERE',
          // OR
          token: 'YOUR_TOKEN_HERE',
          image: byteArrayImage,
          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) {

  }
copied to clipboard

Item Label API #

After an image is captured, you can send it to our cloud service for further logistics processing like extracting data from an item label. You can do that using the following methods:

  void makeItemLabelAPICall(FlutterToPluginCommunicator? sender, Uint8List byteArrayImage, List<String> codes) {
    sender?.callItemLabelApi(
          apiKey: 'YOUR_API_KEY_HERE',
          // OR
          token: 'YOUR_TOKEN_HERE',
          image: byteArrayImage);
  }

  // You will get the response from API in following functions:
  @override void onOnlineItemLabelResult(Map<String, dynamic> result) {

  }

  // Or in case of any error:
  @override void onScanError(String error) {

  }
copied to clipboard

Document Classification API #

After an image is captured, you can send it to our cloud service for identifying the class of the document in that image. You can do that using the following methods:

  void makeDocumentClassificationAPICall(FlutterToPluginCommunicator? sender, Uint8List byteArrayImage, List<String> codes) {
    sender?.callItemLabelApi(
          apiKey: 'YOUR_API_KEY_HERE',
          // OR
          token: 'YOUR_TOKEN_HERE',
          image: byteArrayImage);
  }

  // You will get the response from API in following functions:
  @override void onOnlineDocumentClassificationResult(Map<String, dynamic> result) {

  }

  // Or in case of any error:
  @override void onScanError(String error) {

  }
copied to clipboard

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(OnDeviceOCRManagerCommunicator? communicator) {
    communicator?.configureOnDeviceOCR(
          apiKey: 'YOUR_API_KEY_HERE',
          // OR
          token: 'YOUR_TOKEN_HERE',
          modelClass: ModelClass.shippingLabel,
          modelSize: ModelSize.large);
  }
copied to clipboard

Important Note:

ModelClass.shippingLabel is supported with ModelSize.micro and Model.large options.

ModelClass.itemLabel is supported with Model.large option.

ModelClass.documentClassification is supported with Model.large option.

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 onError(String error) {

  }
copied to clipboard

After model configuration has been completed, you can send the Base64 image to the following function to extract Shipping Label information from it:

  void getLabelInfoOffline(OnDeviceOCRManagerCommunicator? communicator, Uint8List byteArrayImage, List<String> codes) {
    communicator?.getPredictions(byteArrayImage, codes);
  }

  // You will get the response in following functions:
  @override void onOnDeviceOCRResult(Map<String, dynamic> result) {
    
  }

  // Or in case of any error:
  @override void onError(String error) {

  }
copied to clipboard

Report an issue #

VisionSDK contains internal error reporting mechanism if it faces any issue. Furthermore, if you get a response from On-Device models, that you consider to be incorrect, then you can report it using the following function:

void reportAnIssue(
  OnDeviceOCRManagerCommunicator? communicator,
  String? apiKey,
  String? token,
  required ModelClass modelClass,
  required ModelSize modelSize,
  required String report,
  Map<String, dynamic>? customData,
  String? base64ImageToReportOn
) {
    communicator?.reportAnIssue(
      apiKey: apiKey,
      token: tokem
      modelClass: modelClass,
      modelSize: modelSize,
      report: report,
      customData: customData,
      base64ImageToReportOn: base64ImageToReportOn
    );
  }

  // You will get the response in following functions:
  @override void onReportResult(Map<ReportResult, String> reportResult) {
    switch (reportResult.keys.first) {
      
      case ReportResult.successful:
        // Case where report was submitted successfully.
        break;
        
      case ReportResult.savedForLater:
        // Case where report was saved to be submitted later.
        // NOTE: Saved reports will be submitted by VisionSDK automatically.
        break;
        
      case ReportResult.failed:
        // Case where report submission faced an error. These reports needs to be submitted again.
        val errorMessage = reportResult.values.first;
        break;
        
    }
  }
copied to clipboard

Release Resources #

After client app is done with the On-Device processing, it should release the resources by calling the following method:

void releaseResources(OnDeviceOCRManagerCommunicator? communicator) {
  communicator?.release();
}
copied to clipboard

Native Documentation #

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:

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
}
copied to clipboard

Set the below versions in android->app->build.gradle:

minSdk 29

targetSdk 34

2
likes
140
points
1.07k
downloads

Publisher

verified publisherpackagex.io

Weekly Downloads

2024.09.09 - 2025.03.24

A Flutter plugin package for integrating the Flutter Vision SDK into your Flutter application for scanning Barcodes and QrCodes

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, plugin_platform_interface

More

Packages that depend on fluttervisionsdkplugin