BarcodeReader class final

Reads barcodes from images: photos, files, screenshots, raw pixels.

Decoding runs in the background (an isolate on native platforms, a Web Worker on the web) and never blocks the UI. There is nothing to create or dispose: a reader is a constant configuration, the engine starts on first use. If it cannot start, every call throws EngineException (and the next call tries again).

const reader = BarcodeReader();
final barcode = await reader.read(await file.readAsBytes());

const qr = BarcodeReader(formats: {BarcodeFormat.qrCode});
final all = await qr.readAll(bytes);
Annotations

Constructors

BarcodeReader({Set<BarcodeFormat>? formats, ReaderOptions options = const ReaderOptions()})
Creates a reader.
const

Properties

formats → Set<BarcodeFormat>?
Formats to look for; null means all. Fewer formats read faster. A base symbology includes its variants, see BarcodeFormat.
final
hashCode → int
The hash code for this object.
no setteroverride
options → ReaderOptions
Search strategies.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith({Set<BarcodeFormat>? formats, ReaderOptions? options}) → BarcodeReader
Creates a copy with the given fields replaced.
merge(Iterable<Barcode> parts) → Future<Barcode?>
Joins the parts of a structured append sequence (one message split across several barcodes, see Barcode.sequence) into one barcode that holds the whole message. Returns null until every part is there.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(Uint8List encodedImage) → Future<Barcode?>
Finds the first barcode in an encoded image: any image Flutter decodes (ui.instantiateImageCodec). That is JPEG, PNG, GIF, BMP, WebP and WBMP everywhere, plus what the platform decodes for Flutter: HEIF/HEIC on Android 9+, for one, and on the web whatever the browser decodes. JPEG, PNG, GIF and BMP are decoded in the background by the engine; other formats by Flutter, which takes longer and more memory. A format Flutter cannot decode throws ImageDecodeException: convert it first (e.g. image_picker gives HEIC photos as JPEG by default).
readAll(Uint8List encodedImage, {int? maxBarcodes}) → Future<List<Barcode>>
Finds every barcode in an encoded image, at most maxBarcodes if given (the same limit as ScannerController.maxBarcodes). Takes the same images as read. The engine finds at most 255 barcodes in one image, whatever maxBarcodes says.
readAllPixels(PixelBuffer image, {int? maxBarcodes}) → Future<List<Barcode>>
Finds every barcode in raw pixels, at most maxBarcodes if given, and at most 255 like readAll.
readPixels(PixelBuffer image) → Future<Barcode?>
Finds the first barcode in raw pixels. Returns null if there is none.
toString() → String
The fields that differ from the defaults, e.g. BarcodeReader(formats: {qrCode}, options: ReaderOptions(isPure: true)).
override

Operators

operator ==(Object other) → bool
The equality operator.
override