Navaron Bracke

let the barcode overlay take the corners & capture size as arguments

@@ -138,20 +138,20 @@ class ScannerOverlay extends CustomPainter { @@ -138,20 +138,20 @@ class ScannerOverlay extends CustomPainter {
138 138
139 class BarcodeOverlay extends CustomPainter { 139 class BarcodeOverlay extends CustomPainter {
140 BarcodeOverlay({ 140 BarcodeOverlay({
141 - required this.barcode, 141 + required this.barcodeCorners,
  142 + required this.barcodeSize,
142 required this.boxFit, 143 required this.boxFit,
143 required this.cameraPreviewSize, 144 required this.cameraPreviewSize,
144 - required this.capture,  
145 }); 145 });
146 146
147 - final Barcode barcode; 147 + final List<Offset> barcodeCorners;
  148 + final Size barcodeSize;
148 final BoxFit boxFit; 149 final BoxFit boxFit;
149 final Size cameraPreviewSize; 150 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) {
154 - if (barcode.corners.isEmpty) { 154 + if (barcodeCorners.isEmpty) {
155 return; 155 return;
156 } 156 }
157 157
@@ -175,15 +175,15 @@ class BarcodeOverlay extends CustomPainter { @@ -175,15 +175,15 @@ class BarcodeOverlay extends CustomPainter {
175 final double ratioHeight; 175 final double ratioHeight;
176 176
177 if (!kIsWeb && Platform.isIOS) { 177 if (!kIsWeb && Platform.isIOS) {
178 - ratioWidth = capture.size.width / adjustedSize.destination.width;  
179 - ratioHeight = capture.size.height / adjustedSize.destination.height; 178 + ratioWidth = barcodeSize.width / adjustedSize.destination.width;
  179 + ratioHeight = barcodeSize.height / adjustedSize.destination.height;
180 } else { 180 } else {
181 ratioWidth = cameraPreviewSize.width / adjustedSize.destination.width; 181 ratioWidth = cameraPreviewSize.width / adjustedSize.destination.width;
182 ratioHeight = cameraPreviewSize.height / adjustedSize.destination.height; 182 ratioHeight = cameraPreviewSize.height / adjustedSize.destination.height;
183 } 183 }
184 184
185 final List<Offset> adjustedOffset = []; 185 final List<Offset> adjustedOffset = [];
186 - for (final offset in barcode.corners) { 186 + for (final offset in barcodeCorners) {
187 adjustedOffset.add( 187 adjustedOffset.add(
188 Offset( 188 Offset(
189 offset.dx / ratioWidth + horizontalPadding, 189 offset.dx / ratioWidth + horizontalPadding,