Navaron Bracke

inline the toCorners implementation

1 -import 'package:flutter/material.dart';  
2 -  
3 -List<Offset>? toCorners(List<Map<Object?, Object?>>? data) {  
4 - if (data == null) {  
5 - return null;  
6 - }  
7 -  
8 - return List.unmodifiable(  
9 - data.map((Map<Object?, Object?> e) {  
10 - return Offset(e['x']! as double, e['y']! as double);  
11 - }),  
12 - );  
13 -}  
@@ -6,7 +6,6 @@ import 'package:flutter/cupertino.dart'; @@ -6,7 +6,6 @@ import 'package:flutter/cupertino.dart';
6 import 'package:flutter/foundation.dart'; 6 import 'package:flutter/foundation.dart';
7 import 'package:flutter/services.dart'; 7 import 'package:flutter/services.dart';
8 import 'package:mobile_scanner/mobile_scanner.dart'; 8 import 'package:mobile_scanner/mobile_scanner.dart';
9 -import 'package:mobile_scanner/src/barcode_utility.dart';  
10 9
11 /// The [MobileScannerController] holds all the logic of this plugin, 10 /// The [MobileScannerController] holds all the logic of this plugin,
12 /// where as the [MobileScanner] class is the frontend of this plugin. 11 /// where as the [MobileScanner] class is the frontend of this plugin.
@@ -446,6 +445,8 @@ class MobileScannerController { @@ -446,6 +445,8 @@ class MobileScannerController {
446 break; 445 break;
447 case 'barcodeWeb': 446 case 'barcodeWeb':
448 final barcode = data as Map?; 447 final barcode = data as Map?;
  448 + final corners = barcode?['corners'] as List<Object?>? ?? <Object?>[];
  449 +
449 _barcodesController.add( 450 _barcodesController.add(
450 BarcodeCapture( 451 BarcodeCapture(
451 raw: data, 452 raw: data,
@@ -457,11 +458,13 @@ class MobileScannerController { @@ -457,11 +458,13 @@ class MobileScannerController {
457 format: BarcodeFormat.fromRawValue( 458 format: BarcodeFormat.fromRawValue(
458 barcode['format'] as int? ?? -1, 459 barcode['format'] as int? ?? -1,
459 ), 460 ),
460 - corners: toCorners(  
461 - (barcode['corners'] as List<Object?>? ?? [])  
462 - .cast<Map<Object?, Object?>>(),  
463 - ) ??  
464 - const <Offset>[], 461 + corners: List.unmodifiable(
  462 + corners.cast<Map<Object?, Object?>>().map(
  463 + (Map<Object?, Object?> e) {
  464 + return Offset(e['x']! as double, e['y']! as double);
  465 + },
  466 + ),
  467 + ),
465 ), 468 ),
466 ], 469 ],
467 ), 470 ),