henry_capture_vision_flutter 0.0.5 copy "henry_capture_vision_flutter: ^0.0.5" to clipboard
henry_capture_vision_flutter: ^0.0.5 copied to clipboard

outdated

Dynamsoft Capture Vision Flutter SDK provides the ability to decode barcodes, recognize labels, detect and normalize documents.

Dynamsoft Capture Vision Flutter Edition #

Dynamsoft Capture Vision (DCV) is an aggregating SDK of a series of specific functional products including:

  • Dynamsoft Camera Enhancer (DCE) which provides camera enhancements and UI configuration APIs.
  • Dynamsoft Barcode Reader (DBR) which provides barcode decoding algorithm and APIs.
  • Dynamsoft Label Recognizer (DLR) which provides label content recognizing algorithm and APIs.
  • Dynamsoft Document Normalizer (DDN) which provides document scanning algorithms and APIs.

Note: DCV Flutter edition currently only includes DCE and DBR modules. DLR and DDN modules are still under development and will be included in the future.

Table of Contents

System Requirements #

Flutter & Dart #

  • Flutter version: >=2.0.0
  • Dart version: >=2.12.0 <3.0.0

Android #

  • Supported OS: Android 5.0 (API Level 21) or higher.
  • Supported ABI: armeabi-v7a, arm64-v8a, x86 and x86_64.
  • Development Environment: Android Studio 3.4+ (Android Studio 4.2+ recommended).
  • JDK: 1.8+

iOS #

  • Supported OS: iOS 10.0 or higher.
  • Supported ABI: arm64 and x86_64.
  • Development Environment: Xcode 7.1 and above (Xcode 13.0+ recommended), CocoaPods 1.11.0+.

Installation #

Run the following command:

flutter pub add dynamsoft_capture_vision_flutter

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
   dynamsoft_capture_vision_flutter: ^1.0.0

Build Your Barcode Scanner App #

Now you will learn how to create a simple barcode scanner using Dynamsoft Capture Vision Flutter SDK.

Initialize the Project #

Create a new Flutter project

flutter create simple_barcode_scanner

Include the Library #

View the installation section for how to add the library. In main.dart of your project, import the library.

import 'package:dynamsoft_capture_vision_flutter/dynamsoft_capture_vision_flutter.dart';

License Activation #

The barcode reading module of Dynamsoft Capture Vision needs a valid license to work. In the main() function, add the following code to activate the license.

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  // Put your license here.
  final String licenseKey = '';
  // Initialize the license so that you can use full feature of the Barcode Reader module.
  try {
    await DynamsoftBarcodeReader.initLicense(license: licenseKey);
  } catch (e) {
    print(e);
  }

  runApp(const MyApp());
}

Configure the Barcode Reader #

In this section, we are going to work on the _MyHomePageState class in the newly created project to add the barcode decoding feature.

Define the following attributes:

late final DynamsoftBarcodeReader _barcodeReader;
final DynamsoftCameraView _cameraView = DynamsoftCameraView();
List<BarcodeResult> decodeRes = [];
  • barcodeReader: The object that implements barcode decoding feature. Users can configure barcode decoding settings via this object.
  • cameraView: The camera view that displays the video streaming.
  • decodeResults: An object that will be used to receive and stores barcode decoding result.

Add in the initState add an async method to initialize the barcode reader.

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();
    _configDBR();
  }

  _configDBR() async {
    /// Create an instance of barcode reader.
    _barcodeReader = await DynamsoftBarcodeReader.createInstance();

    /// Receive the barcode decoding results and store the result in object decodeResults
    _barcodeReader.receiveResultStream().listen((List<BarcodeResult> res) {
      if (mounted) {
        setState(() {
          decodeResults = res;
        });
      }
    });

    /// Start barcode decoding when the widget is created.
    _barcodeReader.startScanning();

    /// When overlayVisible is set to true, the decoded barcodes will be highlighted with overlays.
    _cameraView.overlayVisible = true;
  }
}

Add configurations to parse and display the barcode decoding results.

class _MyHomePageState extends State<MyHomePage> {
  ...
  /// Get listItem
  Widget listItem(BuildContext context, int index) {
    BarcodeResult res = decodeResults[index];

    return ListTileTheme(
        textColor: Colors.white,
        // tileColor: Colors.green,
        child: ListTile(
          title: Text(res.barcodeFormatString),
          subtitle: Text(res.barcodeText),
        ));
  }
}

Build the Widget #

Modify the build method to display the decode barcode results on the widget.

class _MyHomePageState extends State<MyHomePage> {
  ...
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('HelloWorld'),
      ),
      body: Stack(
        children: [
          Container(
            child: _cameraView,
          ),
          Container(
            height: 200,
            child: ListView.builder(
              itemBuilder: listItem,
              itemCount: decodeResults.length,
            ),
          ),
        ],
      ));
  }
}

Configure Camera Permissions #

Before you run the project on iOS devices, you have to add the camera permission first. You can use the following steps to add the camera permission.

  1. In the ios folder of your project, find Runner.xcworkspace. Open it.
  2. In the info.plist of the project, add Privacy - Camera Usage Description.

Run the Project #

In terminal, go to the project folder and run the following command:

flutter run

Notes:

  • When running Android, you might have to add minSdkVersion 21 in your build.gradle(app) before running the project on Android devices.
  • When running iOS, you might have to open the Xcode and go to the Deployment Info section of the project to switch the iOS version to 10.0+.

Samples #

You can view all the DCV Flutter samples via the following links:

API References #

View the API reference of DCV Flutter Edition to explore the full feature of DCV:

License #

  • You can also request an extension for your trial license in the customer portal

Contact #

https://www.dynamsoft.com/company/contact/

1
likes
0
points
18
downloads

Publisher

unverified uploader

Weekly Downloads

Dynamsoft Capture Vision Flutter SDK provides the ability to decode barcodes, recognize labels, detect and normalize documents.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on henry_capture_vision_flutter

Packages that implement henry_capture_vision_flutter