barras library

A barcode scanning library that supports 1D, 2D and 3D barcodes (QR codes).

Barras uses ZXing on Android and AVCapture on iOS.

You'll need to handle the camera usage permission. This is out of the scope of this plugin, since applications may already have permission handling. If that is not the case, you can use a plugin like permission_handler.

Using Barras is straightforward. Just call the scan method and wait for the scanned result:

// Open the barcode reading page. Returned data will be null if
// Cancel button is pressed, or if user navigates back
final data = await Barras.scan(context);

You can also customize the appearance of the scanning page:

// Open the barcode reading page. Customize the appearance, changing the
// viewfinder color, size and blinking speed. Returned data will be null
// if Cancel button is pressed, or if user navigates back
final data = await Barras.scan(
  context,
  viewfinderHeight: 120,
  viewfinderWidth: 300,
  scrimColor: Color.fromRGBO(128, 0, 0, 0.5),
  borderColor: Colors.red,
  borderRadius: 24,
  borderStrokeWidth: 2,
  buttonColor: Colors.yellow,
  borderFlashDuration: 250,
  cancelButtonText: "取消",
  successBeep: false,
);

Classes

Barras