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.
 
 
 
 
 
 
Hamed H 1df4f8e49f feature: add CI 2 years ago
.github feature: add CI 2 years ago
.vscode added help page 3 years ago
android Bump gradle from 4.1.0 to 7.1.2 2 years ago
example show black screen if camera not found 2 years ago
ios show black screen if camera not found 2 years ago
lib show black screen if camera not found 2 years ago
test refactores file structure 2 years ago
zxscanner fixed ios scheme issue 2 years ago
.gitignore added cpp source code files 3 years ago
.metadata initial commit 3 years ago
CHANGELOG.md version: 0.4.0 2 years ago
LICENSE updated License file 3 years ago
README.md Update README.md 2 years ago
analysis_options.yaml refactor: applying lint suggestions 2 years ago
init.sh new zxing-cpp 1.3.0 version update 3 years ago
pubspec.yaml show black screen if camera not found 2 years ago

README.md

ZXScanner logo

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
  • Flashlight and pinch to zoom support

Todo

  • Return scanned barcode position and size
  • 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 FlutterZxing
// To read barcode from camera image directly
await FlutterZxing.startCameraProcessing(); // Call this in initState
cameraController?.startImageStream((image) async {
    CodeResult result = await FlutterZxing.processCameraImage(image);
    if (result.isValidBool) {
        debugPrint(result.textString);
    }
    return null;
});
FlutterZxing.stopCameraProcessing(); // Call this in dispose

// To read barcode from XFile, String or url
XFile xFile = XFile('Your image path');
CodeResult? resultFromXFile = await FlutterZxing.readImagePath(xFile);

String path = 'Your image path';
CodeResult? resultFromPath = await FlutterZxing.readImagePathString(path);

String url = 'Your image url';
CodeResult? resultFromUrl = await FlutterZxing.readImageUrl(url);

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 text = 'Text to encode';
final result = FlutterZxing.encodeBarcode(text, 300, 300, Format.QRCode, 10, 0);
if (result.isValidBool) {
    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.