Navaron Bracke

remove toSize() helper

import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
Size toSize(Map data) {
final width = data['width'] as double;
final height = data['height'] as double;
return Size(width, height);
}
List<Offset>? toCorners(List<Map<Object?, Object?>>? data) {
if (data == null) {
return null;
... ...
... ... @@ -287,14 +287,26 @@ class MobileScannerController {
torchState.value = TorchState.on;
}
isStarting = false;
return startArguments.value = MobileScannerArguments(
size: kIsWeb
? Size(
final Size size;
if (kIsWeb) {
size = Size(
startResult['videoWidth'] as double? ?? 0,
startResult['videoHeight'] as double? ?? 0,
)
: toSize(startResult['size'] as Map? ?? {}),
);
} else {
final Map<Object?, Object?>? sizeInfo =
startResult['size'] as Map<Object?, Object?>?;
size = Size(
sizeInfo?['width'] as double? ?? 0,
sizeInfo?['height'] as double? ?? 0,
);
}
isStarting = false;
return startArguments.value = MobileScannerArguments(
size: size,
hasTorch: hasTorch,
textureId: kIsWeb ? null : startResult['textureId'] as int?,
webId: kIsWeb ? startResult['ViewID'] as String? : null,
... ...