yushulx / flutter_barcode_sdk

Build barcode QR detection apps for Windows, Linux, macOS, Android, iOS and web.
https://pub.dev/packages/flutter_barcode_sdk
MIT License
47 stars 18 forks source link
android barcode datamatrix flutter ios linux macos pdf417 qrcode web windows

flutter_barcode_sdk

pub.dev

The Flutter barcode Qr reading SDK 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. The SDK encapsulates the low-level decoding functions of the Dynamsoft Barcode Reader SDK, including file decoding and image buffer decoding. The project is maintained by community contributors.

For live camera scenarios, it is recommended to use the official Dynamsoft Capture Vision Flutter Edition, which is better than combining the Flutter camera plugin and the Flutter barcode SDK.

Getting a License Key for Dynamsoft Barcode Reader

Supported Platforms

Supported Barcode Symbologies

SDK Version Used for Different Platforms

Dynamsoft Barcode Reader Android iOS Windows Linux macOS Web
Version 9.6.20 9.6.21 9.6.20 9.6.20 9.6.20 9.6.20

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:

Web

In index.html, include:

<script src="https://cdn.jsdelivr.net/npm/dynamsoft-javascript-barcode@9.6.20/dist/dbr.js"></script>

API Compatibility

Methods Android iOS Windows Linux macOS Web
Future<void> setLicense(String license) async :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Future<List<BarcodeResult>> decodeFile(String filename) async :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Future<List<BarcodeResult>> decodeImageBuffer(Uint8List bytes, int width, int height, int stride, int format) async :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Future<int> setBarcodeFormats(int formats) async :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Future<String> getParameters() async :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Future<int> setParameters(String params) async :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Future<void> init() async :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:

Usage

Try Barcode Decoding Example

Mobile

The example allows users to scan barcode Qr code via the camera video stream and read barcode QRCode by a static 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

cd example
# Windows
flutter run -d windows

# Linux
flutter run -d linux

# macOS
flutter run -d macos

Web Browser

cd example
flutter run -d chrome

flutter web barcode reader