diff --git a/lib/src/qr_code_scanner.dart b/lib/src/qr_code_scanner.dart index 22876ee..9faf3af 100644 --- a/lib/src/qr_code_scanner.dart +++ b/lib/src/qr_code_scanner.dart @@ -334,7 +334,7 @@ class QRViewController { await channel.invokeMethod('setDimensions', { 'width': renderBox.size.width, 'height': renderBox.size.height, - 'scanArea': overlay?.cutOutSize ?? 0, + 'scanArea': overlay?.cutOutWidth ?? 0,//Todo 'scanAreaOffset': overlay?.cutOutBottomOffset ?? 0 }); return true; @@ -346,7 +346,7 @@ class QRViewController { return false; } await channel.invokeMethod('changeScanArea', { - 'cutOutSize': overlay.cutOutSize, + 'cutOutSize': overlay.cutOutWidth,//Todo 'cutOutBottomOffset': overlay.cutOutBottomOffset }); return true; diff --git a/lib/src/qr_scanner_overlay_shape.dart b/lib/src/qr_scanner_overlay_shape.dart index 1d233f1..b101652 100644 --- a/lib/src/qr_scanner_overlay_shape.dart +++ b/lib/src/qr_scanner_overlay_shape.dart @@ -76,10 +76,11 @@ class QrScannerOverlayShape extends ShapeBorder { final borderWidthSize = width / 2; final height = rect.height; final borderOffset = borderWidth / 2; - final _borderLength = borderLength > cutOutSize / 2 + borderWidth * 2 + final _borderLength = borderLength > min(cutOutHeight, cutOutHeight) / 2 + borderWidth * 2 ? borderWidthSize / 2 : borderLength; - final _cutOutSize = cutOutSize < width ? cutOutSize : width - borderOffset; + final _cutOutWidth = cutOutWidth < width ? cutOutWidth : width - borderOffset; + final _cutOutHeight = cutOutHeight < height ? cutOutHeight : height - borderOffset; final backgroundPaint = Paint() ..color = overlayColor @@ -96,14 +97,14 @@ class QrScannerOverlayShape extends ShapeBorder { ..blendMode = BlendMode.dstOut; final cutOutRect = Rect.fromLTWH( - rect.left + width / 2 - _cutOutSize / 2 + borderOffset, + rect.left + width / 2 - _cutOutWidth / 2 + borderOffset, -cutOutBottomOffset + rect.top + height / 2 - - _cutOutSize / 2 + + _cutOutHeight / 2 + borderOffset, - _cutOutSize - borderOffset * 2, - _cutOutSize - borderOffset * 2, + _cutOutWidth - borderOffset * 2, + _cutOutHeight - borderOffset * 2, ); canvas