Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Khoren Markosyan 11a99a654b added EncodeParams, Params renamed to DecodeParams 2 years ago
.github Bump actions/setup-java from 3.6.0 to 3.9.0 2 years ago
.vscode fixed memory leak 2 years ago
android added fastlane screengrab support for android 3 years ago
example added EncodeParams, Params renamed to DecodeParams 2 years ago
ios fixed memory leak 2 years ago
lib added EncodeParams, Params renamed to DecodeParams 2 years ago
test refactores file structure 3 years ago
zxscanner updated pubspec 2 years ago
.gitignore added cpp source code files 3 years ago
.metadata initial commit 3 years ago
CHANGELOG.md version: 0.9.1 2 years ago
LICENSE updated License file 3 years ago
README.md fixed inverted issues 2 years ago
analysis_options.yaml fixed share issue on ipad 2 years ago
init.sh update CMakeLists file 2 years ago
init_win.ps1 fixed win script 2 years ago
melos.yaml integrated melos 2 years ago
pubspec.yaml version: 0.9.1 2 years ago

README.md

ZXScanner logo

Download on the App Store Download on the Google Play

flutter_zxing

A barcode and QR code scanner based on ZXing C++ library natively in Flutter with Dart FFI.

Demo Screenshots

01_scanner_screen  02_creator_screen 

Supported Barcode Formats

1D product 1D industrial 2D
UPC-A Code 39 QR Code
UPC-E Code 93 DataMatrix
EAN-8 Code 128 Aztec
EAN-13 Codabar PDF417
DataBar ITF MaxiCode (beta)
DataBar Expanded

Features

  • Scan barcode from camera stream, image path or url
  • Scan multiple barcodes from camera stream, image path or url
  • Create barcode from text
  • Return scanned barcode position points
  • Flashlight and pinch to zoom support

Todo

  • Write tests

Getting Started

To read barcode

import 'package:flutter_zxing/flutter_zxing.dart';

// Use ReaderWidget to quickly read barcode from camera image
@override
Widget build(BuildContext context) {
    return Scaffold(
        body: ReaderWidget(
            onScan: (result) async {
                // Do something with the result
            },
        ),
    ),
);

// Or use flutter_zxing plugin methods 
// To read barcode from camera image directly
await zx.startCameraProcessing(); // Call this in initState

cameraController?.startImageStream((image) async {
    Code result = await zx.processCameraImage(image);
    if (result.isValid) {
        debugPrint(result.text);
    }
    return null;
});

zx.stopCameraProcessing(); // Call this in dispose

// To read barcode from XFile, String, url or Uint8List bytes
XFile xFile = XFile('Your image path');
Code? resultFromXFile = await zx.readBarcodeImagePath(xFile);

String path = 'Your local image path';
Code? resultFromPath = await zx.readBarcodeImagePathString(path);

String url = 'Your remote image url';
Code? resultFromUrl = await zx.readBarcodeImageUrl(url);

Uint8List bytes = Uint8List.fromList(yourImageBytes);
Code? resultFromBytes = await zx.readBarcode(bytes);

To create barcode

import 'package:flutter_zxing/flutter_zxing.dart';
import 'dart:typed_data';
import 'package:image/image.dart' as imglib;

// Use WriterWidget to quickly create barcode
@override
Widget build(BuildContext context) {
    return Scaffold(
        body: WriterWidget(
            onSuccess: (result, bytes) {
                // Do something with the result
            },
            onError: (error) {
                // Do something with the error
            },
        ),
    ),
);

// Or use FlutterZxing to create barcode directly
final result = zx.encodeBarcode(
    'Text to encode',
    format: Format.QRCode,
    width: 120,
    height: 120,
    margin: 10,
    eccLevel: 0,
);
if (result.isValid) {
    final img = imglib.Image.fromBytes(width, height, result.bytes);
    final encodedBytes = Uint8List.fromList(imglib.encodeJpg(img));
    // use encodedBytes as you wish
}

License

MIT License. See LICENSE.