Navaron Bracke

let the barcode overlay take the camera preview size as argument

@@ -139,15 +139,15 @@ class ScannerOverlay extends CustomPainter { @@ -139,15 +139,15 @@ class ScannerOverlay extends CustomPainter {
139 class BarcodeOverlay extends CustomPainter { 139 class BarcodeOverlay extends CustomPainter {
140 BarcodeOverlay({ 140 BarcodeOverlay({
141 required this.barcode, 141 required this.barcode,
142 - required this.arguments,  
143 required this.boxFit, 142 required this.boxFit,
  143 + required this.cameraPreviewSize,
144 required this.capture, 144 required this.capture,
145 }); 145 });
146 146
147 - final BarcodeCapture capture;  
148 final Barcode barcode; 147 final Barcode barcode;
149 - final MobileScannerArguments arguments;  
150 final BoxFit boxFit; 148 final BoxFit boxFit;
  149 + final Size cameraPreviewSize;
  150 + final BarcodeCapture capture;
151 151
152 @override 152 @override
153 void paint(Canvas canvas, Size size) { 153 void paint(Canvas canvas, Size size) {
@@ -155,7 +155,7 @@ class BarcodeOverlay extends CustomPainter { @@ -155,7 +155,7 @@ class BarcodeOverlay extends CustomPainter {
155 return; 155 return;
156 } 156 }
157 157
158 - final adjustedSize = applyBoxFit(boxFit, arguments.size, size); 158 + final adjustedSize = applyBoxFit(boxFit, cameraPreviewSize, size);
159 159
160 double verticalPadding = size.height - adjustedSize.destination.height; 160 double verticalPadding = size.height - adjustedSize.destination.height;
161 double horizontalPadding = size.width - adjustedSize.destination.width; 161 double horizontalPadding = size.width - adjustedSize.destination.width;
@@ -178,8 +178,8 @@ class BarcodeOverlay extends CustomPainter { @@ -178,8 +178,8 @@ class BarcodeOverlay extends CustomPainter {
178 ratioWidth = capture.size.width / adjustedSize.destination.width; 178 ratioWidth = capture.size.width / adjustedSize.destination.width;
179 ratioHeight = capture.size.height / adjustedSize.destination.height; 179 ratioHeight = capture.size.height / adjustedSize.destination.height;
180 } else { 180 } else {
181 - ratioWidth = arguments.size.width / adjustedSize.destination.width;  
182 - ratioHeight = arguments.size.height / adjustedSize.destination.height; 181 + ratioWidth = cameraPreviewSize.width / adjustedSize.destination.width;
  182 + ratioHeight = cameraPreviewSize.height / adjustedSize.destination.height;
183 } 183 }
184 184
185 final List<Offset> adjustedOffset = []; 185 final List<Offset> adjustedOffset = [];