6 Best Barcode and QR Packages for Flutter

Barcode and QR code scanning are essential features for many mobile applications, ranging from inventory management to e-commerce.

The following are the best Flutter libraries for generating and scanning barcodes:

Create barcode

barcode

barcode is a Dart library that can generate generic drawing operations. It is the base to create flutter widgets or pdf barcodes. There are many packages that depend on this package to generate PDF and SVG barcodes.

// Create a DataMatrix barcode
final dm = Barcode.dataMatrix();

final me = MeCard.wifi(
  ssid: 'My Neighbor Wifi ',
  password: 'somelongpasswith12345',
);

// Generate a SVG with a barcode that configures the wifi access
final svg = bc.toSvg(me.toString(), width: 300, height: 300);

// Save the image
await File('neighbor_wifi.svg').writeAsString(svg);

It supports both 1D and 2D barcodes.

barcode_widget

This widget uses pub:barcode (the library above) to generate any supported barcodes.

BarcodeWidget(
  barcode: Barcode.ean13(),
  data: 'EAN14 format product code data',
  errorBuilder: (context, error) => Center(child: Text(error)),
);

Scan barcode

flutter_barcode_scanner

This is a barcode scanning package that supports the scanning of 1D barcodes, and QR codes on Android and iOS.

String barcodeScanRes = await FlutterBarcodeScanner.scanBarcode(
                                                    COLOR_CODE, 
                                                    CANCEL_BUTTON_TEXT, 
                                                    isShowFlashIcon, 
                                                    scanMode);

qrscan

This is a simple plugin to scan for QR codes. It supports scanning BR-CODE or QR-CODE.

import 'package:qrscan/qrscan.dart' as scanner;

String cameraScanResult = await scanner.scan();

qr_flutter

QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter.

QrImage(
  data: "22345678910",
  version: QrVersions.auto,
  size: 300.0,
),

qr_code_scanner

This is a QR code scanner that can be embedded inside Flutter that works on both iOS and Android.

class _QRViewExampleState extends State<QRViewExample> {
  final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
  var qrText = "";
  QRViewController controller;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          Expanded(
            flex: 5,
            child: QRView(
              key: qrKey,
              onQRViewCreated: _onQRViewCreated,
            ),
          ),
          Expanded(
            flex: 1,
            child: Center(
              child: Text('Scan result: $qrText'),
            ),
          )
        ],
      ),
    );
  }

  void _onQRViewCreated(QRViewController controller) {
    this.controller = controller;
    controller.scannedDataStream.listen((scanData) {
      setState(() {
        qrText = scanData;
      });
    });
  }

  @override
  void dispose() {
    controller?.dispose();
    super.dispose();
  }
}

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top