CodeScanner class

Scans camera frames for barcodes / QR codes of a selectable kind.

Runs decoding on a persistent worker isolate with drop-latest backpressure (via CameraFrameProcessor), so scanning never stalls the preview. Uses the adaptive resolution ladder + last-hit cache internally.

final scanner = CodeScanner(kind: CodeScanKind.qr);
await scanner.start(controller.frames);
scanner.results.listen((code) => print(code));       // confirmed
scanner.detections.listen((d) => highlight(d));      // every raw hit

Constructors

CodeScanner({CodeScanKind kind = CodeScanKind.all, ScanMode mode = ScanMode.continuous, int confirmationFrames = 2, Duration cooldown = const Duration(milliseconds: 1500), double windowFraction = kScannerWindowFraction, FrameHandler<CodeResult?>? handler})

Properties

detections → Stream<CodeResult>
Every raw per-frame detection (unconfirmed) — drive live highlights with this; act on results.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isArmed → bool
Whether a one-shot scanner is still waiting for its result.
no setter
kind → CodeScanKind
Which code family to look for. Fixed per instance — create a new scanner to change it (the worker isolate restarts either way).
final
mode → ScanMode
Continuous (default) or one-shot delivery — see ScanMode.
final
results → Stream<CodeResult>
CONFIRMED results: same payload on N consecutive frames, deduplicated by the cooldown. In ScanMode.oneShot, at most one until resume.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
stats → Stream<FrameProcessStats>
Per-frame decode timing — emitted for EVERY analysed frame (hit or miss). Feed to a benchmarking HUD: stats.elapsedMillis is how long the full engine pass took on the worker isolate.
no setter

Methods

dispose() → Future<void>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resume() → void
Re-arms a ScanMode.oneShot scanner for the next scan.
start(Stream<CameraFrame> frames, {bool direct = false}) → Future<void>
Spawns the worker and starts consuming frames.
toString() → String
A string representation of this object.
inherited

Operators

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