scanWindow property
The scan window rectangle for the barcode scanner.
If this is not null, the barcode scanner will only scan barcodes which intersect this rectangle.
This rectangle is relative to the layout size of the camera preview widget in the widget tree, rather than the actual size of the camera preview output. This is because the size of the camera preview widget might not be the same as the size of the camera output.
For example, the applied fit has an effect on the size of the camera preview widget, while the camera preview size remains the same.
The following example shows a scan window that is centered, fills half the height and one third of the width of the layout:
LayoutBuider(
builder: (BuildContext context, BoxConstraints constraints) {
final Size layoutSize = constraints.biggest;
final double scanWindowWidth = layoutSize.width / 3;
final double scanWindowHeight = layoutSize.height / 2;
final Rect scanWindow = Rect.fromCenter(
center: layoutSize.center(Offset.zero),
width: scanWindowWidth,
height: scanWindowHeight,
);
}
);
Implementation
final Rect? scanWindow;