flutter_zxing 0.1.2 copy "flutter_zxing: ^0.1.2" to clipboard
flutter_zxing: ^0.1.2 copied to clipboard

outdated

A barcode scanner and generator natively in Flutter with Dart FFI based on ZXing.

flutter_zxing #

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

Demo Screenshots #

04_trending_repository_screen  04_trending_repository_screen  04_trending_repository_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 #

  • ✅ Read barcode from camera
  • ✅ Read barcode from gallery
  • ✅ Create barcode from text
  • ❌ Read multiple barcodes from camera or gallery
  • ❌ Return scanned barcode position and size

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
cameraController?.startImageStream((img) async {
    final bytes = await convertImage(img);
    final result = FlutterZxing.readBarcode(bytes, Format.Any, img.width, img.height, 200, 200);
    if (result.isValidBool) {
        debugPrint(result.textString);
    }
    return null;
});

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 read barcode from camera image
@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.

95
likes
0
pub points
95%
popularity

Publisher

unverified uploader

A barcode scanner and generator natively in Flutter with Dart FFI based on ZXing.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

camera, ffi, flutter, flutter_beep, image

More

Packages that depend on flutter_zxing