setScanRegion method

void setScanRegion(
  1. Rect? normalizedRegion
)

Restricts decoding to a rectangle of the preview, in normalized coordinates. Cutting the search area is the cheapest speed win there is.

Implementation

void setScanRegion(Rect? normalizedRegion) {
  final UCameraSize preview = value.previewSize;
  if (normalizedRegion == null || preview.width == 0) {
    _config = _config.copyWith(scanOptions: _config.scanOptions.copyWith());
    return;
  }
  _config = _config.copyWith(
    scanOptions: _config.scanOptions.copyWith(
      region: Rect.fromLTWH(
        normalizedRegion.left * preview.width,
        normalizedRegion.top * preview.height,
        normalizedRegion.width * preview.width,
        normalizedRegion.height * preview.height,
      ),
    ),
  );
}