GithubHelp home page GithubHelp logo

shuchongqj / flutter_barcode_sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yushulx/flutter_barcode_sdk

0.0 0.0 0.0 54.02 MB

License: Other

Java 1.61% Swift 2.02% Objective-C 33.73% Dart 5.29% HTML 0.25% CMake 2.35% C++ 6.59% C 47.56% Ruby 0.61%

flutter_barcode_sdk's Introduction

flutter_barcode_sdk

pub.dev

The Flutter barcode SDK plugin is a wrapper for Dynamsoft Barcode Reader SDK. It aims to cover Android, iOS, Web, Windows, Linux and macOS, supporting linear barcode, QR Code, DataMatrix, MaxiCode, PDF417, etc.

What You Should Know About Dynamsoft Barcode SDK

Build Configuration

Android

Change the minimum Android sdk version to 21 (or higher) in your android/app/build.gradle file.

minSdkVersion 21

iOS

Add the keys to ios/Runner/Info.plist to make camera work:

<key>NSCameraUsageDescription</key>
<string>Can I use the camera please?</string>
<key>NSMicrophoneUsageDescription</key>
<string>Can I use the mic please?</string>

Desktop

Windows & Linux

Install CMake and platform-specific C++ compiler.

macOS

Install Xcode.

To make the demo app work on macOS:

  • Disable com.apple.security.app-sandbox and enable com.apple.security.files.user-selected.read-write in example/macos/Runner/DebugProfile.entitlements:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
      <key>com.apple.security.app-sandbox</key>
      <false/>
      <key>com.apple.security.cs.allow-jit</key>
      <true/>
      <key>com.apple.security.network.server</key>
      <true/>
      <key>com.apple.security.files.user-selected.read-write</key>
      <true/>
    </dict>
    </plist>
  • Import DynamsoftBarcodeReader.h to the bridging header file.

    macOS bridging header

Web

Include <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dbr.js" data-productKeys="PRODUCT-KEYS"></script> to index.html.

There are two editions: compact edition and full edtion. The compact edition is used as the default. To enable the full edition, you need to add the following line to index.html after including the JS library.

<script>
  Dynamsoft.DBR.BarcodeReader._bUseFullFeature = true;
</script>

Try Barcode Decoding Example

Mobile

The example allows users to scan barcodes via the camera video stream in real-time or read barcodes by taking a picture.

cd example
flutter run -d <device>

Video Scan

flutter barcode scanner

Picture Scan

flutter barcode reader

For building Android release app, configure build.gradle and corresponding proguard file:

build.gradle

buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

proguard-rules.pro

-keep class com.dynamsoft.dbr.** { *; }

Windows, Linux and macOS Desktop

Input a valid image path for barcode decoding.

flutter windows barcode reader

  • Windows

    cd example
    flutter run -d windows
    
  • Linux

    cd example
    flutter run -d linux
    
  • macOS

    cd example
    flutter run -d macos
    

Web Browser

cd example
flutter run -d chrome

Barcode Reader

flutter web barcode reader

Barcode Scanner

flutter web barcode scanner

Currently Supported Platforms

  • Android
  • iOS
  • Windows
  • Linux
  • macOS
  • Web

API Compatibility

Methods Android iOS Windows Linux macOS Web
Future<void> setLicense(String license) async ✔️ ✔️ ✔️ ✔️ ✔️
Future<List<BarcodeResult>> decodeFile(String filename) async ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Future<List<BarcodeResult>> decodeFileBytes(Uint8List bytes) async ✔️ ✔️ ✔️
Future<List<BarcodeResult>> decodeImageBuffer(Uint8List bytes, int width, int height, int stride, int format) async ✔️ ✔️ ✔️ ✔️
Future<void> decodeVideo(Function callback) async ✔️
Future<void> closeVideo() async ✔️
Future<int> setBarcodeFormats(int formats) async ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Future<String> getParameters() async ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Future<int> setParameters(String params) async ✔️ ✔️ ✔️ ✔️ ✔️ ✔️

Supported Barcode Symbologies

  • Linear Barcodes (1D)

    • Code 39 (including Code 39 Extended)
    • Code 93
    • Code 128
    • Codabar
    • Interleaved 2 of 5
    • EAN-8
    • EAN-13
    • UPC-A
    • UPC-E
    • Industrial 2 of 5
  • 2D Barcodes

    • QR Code (including Micro QR Code and Model 1)
    • Data Matrix
    • PDF417 (including Micro PDF417)
    • Aztec Code
    • MaxiCode (mode 2-5)
    • DotCode
  • Patch Code

  • GS1 Composite Code

  • GS1 DataBar

    • Omnidirectional,
    • Truncated, Stacked, Stacked
    • Omnidirectional, Limited,
    • Expanded, Expanded Stacked
  • Postal Codes

    • USPS Intelligent Mail
    • Postnet
    • Planet
    • Australian Post
    • UK Royal Mail

Usage

  • Initialize Flutter barcode sdk:

    // Windows, Linux, macOS, iOS and Android
    _barcodeReader = FlutterBarcodeSdk();
      
    // Web
    _barcodeReader = FlutterBarcodeSdk();
    await _barcodeReader.init();
  • Set a license key:

    _barcodeReader.setLicense('LICENSE-KEY');
  • Read barcodes from an image file:

    List<BarcodeResult> results = await _barcodeReader.decodeFile(image-path);
  • Read barcodes from image file bytes:

    Uint8List bytes = await File(image-path).readAsBytes();
    List<BarcodeResult> results = await _barcodeReader.decodeFileBytes(bytes);
  • Read barcodes from video stream CameraImage:

    CameraImage availableImage;
    int format = FlutterBarcodeSdk.IF_UNKNOWN;
    
    switch (availableImage.format.group) {
      case ImageFormatGroup.yuv420:
        format = FlutterBarcodeSdk.IF_YUV420;
        break;
      case ImageFormatGroup.bgra8888:
        format = FlutterBarcodeSdk.IF_BRGA8888;
        break;
      default:
        format = FlutterBarcodeSdk.IF_UNKNOWN;
    }
    
    List<BarcodeResult> results = _barcodeReader.decodeImageBuffer(
                  availableImage.planes[0].bytes,
                  availableImage.width,
                  availableImage.height,
                  availableImage.planes[0].bytesPerRow,
                  format);
  • Read barcodes from web browser video stream:

    _barcodeReader.decodeVideo(
                                (results) => {updateResults(results)});
  • Set barcode formats:

    await _barcodeReader.setBarcodeFormats(BarcodeFormat.ALL);
  • Get current barcode detection parameters:

    String params = await _barcodeReader.getParameters();
    // Convert parameters to a JSON object.
    dynamic obj = jsonDecode(params);
    // Modify parameters.
    if (obj['ImageParameter'] != null) {
      obj['ImageParameter']['DeblurLevel'] = 5;
    } else
      obj['deblurLevel'] = 5;
  • Set barcode detection parameters:

    int ret = await _barcodeReader.setParameters(json.encode(obj));

How to Use the License Key

Mobile

No license required. Instead, you need to get an private organization ID and update the plugin code:

parameters.organizationID = "200001";

By default, the public organization ID 200001 authorize developers to use the SDK for 7 days.

Desktop

Invoke the setLicense() method:

_barcodeReader.setLicense('LICENSE-KEY');

Web

Update the PRODUCT-KEYS :

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/dbr.js" data-productKeys="PRODUCT-KEYS"></script>
<script>
  Dynamsoft.DBR.BarcodeReader._bUseFullFeature = true;
</script>

License Agreement

https://www.dynamsoft.com/Products/barcode-reader-license-agreement.aspx

Contact Us

[email protected]

flutter_barcode_sdk's People

Contributors

yushulx avatar zyunique avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.