Navaron Bracke

fix type of 'raw' attribute; remove width & height; update a comment

  1 +## NEXT
  2 +BREAKING CHANGES:
  3 +* The `width` and `height` of `BarcodeCapture` have been removed, in favor of `size`.
  4 +* The `raw` attribute is now `Object?` instead of `dynamic`, so that it participates in type promotion.
  5 +
1 ## 4.0.1 6 ## 4.0.1
2 Bugs fixed: 7 Bugs fixed:
3 * [iOS] Fixed a crash with a nil capture session when starting the camera. (thanks @navaronbracke !) 8 * [iOS] Fixed a crash with a nil capture session when starting the camera. (thanks @navaronbracke !)
@@ -434,13 +434,18 @@ class MobileScannerController { @@ -434,13 +434,18 @@ class MobileScannerController {
434 final parsed = (data as List) 434 final parsed = (data as List)
435 .map((value) => Barcode.fromNative(value as Map)) 435 .map((value) => Barcode.fromNative(value as Map))
436 .toList(); 436 .toList();
  437 +
  438 + final double? width = event['width'] as double?;
  439 + final double? height = event['height'] as double?;
  440 +
437 _barcodesController.add( 441 _barcodesController.add(
438 BarcodeCapture( 442 BarcodeCapture(
439 raw: data, 443 raw: data,
440 barcodes: parsed, 444 barcodes: parsed,
441 image: event['image'] as Uint8List?, 445 image: event['image'] as Uint8List?,
442 - width: event['width'] as double?,  
443 - height: event['height'] as double?, 446 + size: width == null || height == null
  447 + ? Size.zero
  448 + : Size(width, height),
444 ), 449 ),
445 ); 450 );
446 case 'barcodeMac': 451 case 'barcodeMac':
@@ -147,7 +147,9 @@ class Barcode { @@ -147,7 +147,9 @@ class Barcode {
147 /// The SMS message that is embedded in the barcode. 147 /// The SMS message that is embedded in the barcode.
148 final SMS? sms; 148 final SMS? sms;
149 149
150 - /// The type of the [format] of the barcode. 150 + /// The contextual type of the [format] of the barcode.
  151 + ///
  152 + /// For example: TYPE_TEXT, TYPE_PRODUCT, TYPE_URL, etc.
151 /// 153 ///
152 /// For types that are recognized, 154 /// For types that are recognized,
153 /// but could not be parsed correctly, [BarcodeType.text] will be returned. 155 /// but could not be parsed correctly, [BarcodeType.text] will be returned.
@@ -6,38 +6,25 @@ import 'package:mobile_scanner/src/objects/barcode.dart'; @@ -6,38 +6,25 @@ import 'package:mobile_scanner/src/objects/barcode.dart';
6 /// This class represents a scanned barcode. 6 /// This class represents a scanned barcode.
7 class BarcodeCapture { 7 class BarcodeCapture {
8 /// Create a new [BarcodeCapture] instance. 8 /// Create a new [BarcodeCapture] instance.
9 - BarcodeCapture({ 9 + const BarcodeCapture({
10 this.barcodes = const <Barcode>[], 10 this.barcodes = const <Barcode>[],
11 - double? height,  
12 this.image, 11 this.image,
13 this.raw, 12 this.raw,
14 - double? width,  
15 - }) : size =  
16 - width == null && height == null ? Size.zero : Size(width!, height!); 13 + this.size = Size.zero,
  14 + });
17 15
18 /// The list of scanned barcodes. 16 /// The list of scanned barcodes.
19 final List<Barcode> barcodes; 17 final List<Barcode> barcodes;
20 18
21 /// The bytes of the image that is embedded in the barcode. 19 /// The bytes of the image that is embedded in the barcode.
22 /// 20 ///
23 - /// This null if [MobileScannerController.returnImage] is false. 21 + /// This null if [MobileScannerController.returnImage] is false,
  22 + /// or if there is no available image.
24 final Uint8List? image; 23 final Uint8List? image;
25 24
26 /// The raw data of the scanned barcode. 25 /// The raw data of the scanned barcode.
27 - final dynamic raw; // TODO: this should be `Object?` instead of dynamic 26 + final Object? raw;
28 27
29 /// The size of the scanned barcode. 28 /// The size of the scanned barcode.
30 final Size size; 29 final Size size;
31 -  
32 - /// The width of the scanned barcode.  
33 - ///  
34 - /// Prefer using `size.width` instead,  
35 - /// as this getter will be removed in the future.  
36 - double get width => size.width;  
37 -  
38 - /// The height of the scanned barcode.  
39 - ///  
40 - /// Prefer using `size.height` instead,  
41 - /// as this getter will be removed in the future.  
42 - double get height => size.height;  
43 } 30 }