Showing
1 changed file
with
15 additions
and
7 deletions
| 1 | import 'dart:io'; | 1 | import 'dart:io'; |
| 2 | 2 | ||
| 3 | +import 'package:flutter/foundation.dart'; | ||
| 3 | import 'package:flutter/material.dart'; | 4 | import 'package:flutter/material.dart'; |
| 4 | import 'package:mobile_scanner/mobile_scanner.dart'; | 5 | import 'package:mobile_scanner/mobile_scanner.dart'; |
| 5 | 6 | ||
| @@ -150,7 +151,10 @@ class BarcodeOverlay extends CustomPainter { | @@ -150,7 +151,10 @@ class BarcodeOverlay extends CustomPainter { | ||
| 150 | 151 | ||
| 151 | @override | 152 | @override |
| 152 | void paint(Canvas canvas, Size size) { | 153 | void paint(Canvas canvas, Size size) { |
| 153 | - if (barcode.corners == null) return; | 154 | + if (barcode.corners == null) { |
| 155 | + return; | ||
| 156 | + } | ||
| 157 | + | ||
| 154 | final adjustedSize = applyBoxFit(boxFit, arguments.size, size); | 158 | final adjustedSize = applyBoxFit(boxFit, arguments.size, size); |
| 155 | 159 | ||
| 156 | double verticalPadding = size.height - adjustedSize.destination.height; | 160 | double verticalPadding = size.height - adjustedSize.destination.height; |
| @@ -167,12 +171,16 @@ class BarcodeOverlay extends CustomPainter { | @@ -167,12 +171,16 @@ class BarcodeOverlay extends CustomPainter { | ||
| 167 | horizontalPadding = 0; | 171 | horizontalPadding = 0; |
| 168 | } | 172 | } |
| 169 | 173 | ||
| 170 | - final ratioWidth = | ||
| 171 | - (Platform.isIOS ? capture.width! : arguments.size.width) / | ||
| 172 | - adjustedSize.destination.width; | ||
| 173 | - final ratioHeight = | ||
| 174 | - (Platform.isIOS ? capture.height! : arguments.size.height) / | ||
| 175 | - adjustedSize.destination.height; | 174 | + final double ratioWidth; |
| 175 | + final double ratioHeight; | ||
| 176 | + | ||
| 177 | + if (!kIsWeb && Platform.isIOS) { | ||
| 178 | + ratioWidth = capture.size.width / adjustedSize.destination.width; | ||
| 179 | + ratioHeight = capture.size.height / adjustedSize.destination.height; | ||
| 180 | + } else { | ||
| 181 | + ratioWidth = arguments.size.width / adjustedSize.destination.width; | ||
| 182 | + ratioHeight = arguments.size.height / adjustedSize.destination.height; | ||
| 183 | + } | ||
| 176 | 184 | ||
| 177 | final List<Offset> adjustedOffset = []; | 185 | final List<Offset> adjustedOffset = []; |
| 178 | for (final offset in barcode.corners!) { | 186 | for (final offset in barcode.corners!) { |
-
Please register or login to post a comment