Showing
2 changed files
with
18 additions
and
12 deletions
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:mobile_scanner/mobile_scanner.dart'; | 2 | import 'package:mobile_scanner/mobile_scanner.dart'; |
| 3 | 3 | ||
| 4 | -Size toSize(Map data) { | ||
| 5 | - final width = data['width'] as double; | ||
| 6 | - final height = data['height'] as double; | ||
| 7 | - return Size(width, height); | ||
| 8 | -} | ||
| 9 | - | ||
| 10 | List<Offset>? toCorners(List<Map<Object?, Object?>>? data) { | 4 | List<Offset>? toCorners(List<Map<Object?, Object?>>? data) { |
| 11 | if (data == null) { | 5 | if (data == null) { |
| 12 | return null; | 6 | return null; |
| @@ -287,14 +287,26 @@ class MobileScannerController { | @@ -287,14 +287,26 @@ class MobileScannerController { | ||
| 287 | torchState.value = TorchState.on; | 287 | torchState.value = TorchState.on; |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | + final Size size; | ||
| 291 | + | ||
| 292 | + if (kIsWeb) { | ||
| 293 | + size = Size( | ||
| 294 | + startResult['videoWidth'] as double? ?? 0, | ||
| 295 | + startResult['videoHeight'] as double? ?? 0, | ||
| 296 | + ); | ||
| 297 | + } else { | ||
| 298 | + final Map<Object?, Object?>? sizeInfo = | ||
| 299 | + startResult['size'] as Map<Object?, Object?>?; | ||
| 300 | + | ||
| 301 | + size = Size( | ||
| 302 | + sizeInfo?['width'] as double? ?? 0, | ||
| 303 | + sizeInfo?['height'] as double? ?? 0, | ||
| 304 | + ); | ||
| 305 | + } | ||
| 306 | + | ||
| 290 | isStarting = false; | 307 | isStarting = false; |
| 291 | return startArguments.value = MobileScannerArguments( | 308 | return startArguments.value = MobileScannerArguments( |
| 292 | - size: kIsWeb | ||
| 293 | - ? Size( | ||
| 294 | - startResult['videoWidth'] as double? ?? 0, | ||
| 295 | - startResult['videoHeight'] as double? ?? 0, | ||
| 296 | - ) | ||
| 297 | - : toSize(startResult['size'] as Map? ?? {}), | 309 | + size: size, |
| 298 | hasTorch: hasTorch, | 310 | hasTorch: hasTorch, |
| 299 | textureId: kIsWeb ? null : startResult['textureId'] as int?, | 311 | textureId: kIsWeb ? null : startResult['textureId'] as int?, |
| 300 | webId: kIsWeb ? startResult['ViewID'] as String? : null, | 312 | webId: kIsWeb ? startResult['ViewID'] as String? : null, |
-
Please register or login to post a comment