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 the Dynamsoft Barcode Reader SDK v9.x. It supports multiple platforms, including Android, iOS, Web, Windows, Linux and macOS, and can read various barcode types such as linear barcode, QR Code, DataMatrix, MaxiCode, PDF417, etc. This SDK encapsulates the low-level decoding functions of the Dynamsoft Barcode Reader, enabling both file and image buffer decoding. The project is actively maintained by community contributors.

For live camera scenarios, it is recommended to use the official Dynamsoft Capture Vision Flutter Edition, as it offers better performance than combining the Flutter camera plugin with the Flutter Barcode SDK.

Getting a License Key for Dynamsoft Barcode Reader

Supported Platforms

Supported Barcode Symbologies

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.42/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