Navaron Bracke

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

## NEXT
BREAKING CHANGES:
* The `width` and `height` of `BarcodeCapture` have been removed, in favor of `size`.
* The `raw` attribute is now `Object?` instead of `dynamic`, so that it participates in type promotion.
## 4.0.1
Bugs fixed:
* [iOS] Fixed a crash with a nil capture session when starting the camera. (thanks @navaronbracke !)
... ...
... ... @@ -434,13 +434,18 @@ class MobileScannerController {
final parsed = (data as List)
.map((value) => Barcode.fromNative(value as Map))
.toList();
final double? width = event['width'] as double?;
final double? height = event['height'] as double?;
_barcodesController.add(
BarcodeCapture(
raw: data,
barcodes: parsed,
image: event['image'] as Uint8List?,
width: event['width'] as double?,
height: event['height'] as double?,
size: width == null || height == null
? Size.zero
: Size(width, height),
),
);
case 'barcodeMac':
... ...
... ... @@ -147,7 +147,9 @@ class Barcode {
/// The SMS message that is embedded in the barcode.
final SMS? sms;
/// The type of the [format] of the barcode.
/// The contextual type of the [format] of the barcode.
///
/// For example: TYPE_TEXT, TYPE_PRODUCT, TYPE_URL, etc.
///
/// For types that are recognized,
/// but could not be parsed correctly, [BarcodeType.text] will be returned.
... ...
... ... @@ -6,38 +6,25 @@ import 'package:mobile_scanner/src/objects/barcode.dart';
/// This class represents a scanned barcode.
class BarcodeCapture {
/// Create a new [BarcodeCapture] instance.
BarcodeCapture({
const BarcodeCapture({
this.barcodes = const <Barcode>[],
double? height,
this.image,
this.raw,
double? width,
}) : size =
width == null && height == null ? Size.zero : Size(width!, height!);
this.size = Size.zero,
});
/// The list of scanned barcodes.
final List<Barcode> barcodes;
/// The bytes of the image that is embedded in the barcode.
///
/// This null if [MobileScannerController.returnImage] is false.
/// This null if [MobileScannerController.returnImage] is false,
/// or if there is no available image.
final Uint8List? image;
/// The raw data of the scanned barcode.
final dynamic raw; // TODO: this should be `Object?` instead of dynamic
final Object? raw;
/// The size of the scanned barcode.
final Size size;
/// The width of the scanned barcode.
///
/// Prefer using `size.width` instead,
/// as this getter will be removed in the future.
double get width => size.width;
/// The height of the scanned barcode.
///
/// Prefer using `size.height` instead,
/// as this getter will be removed in the future.
double get height => size.height;
}
... ...