Navaron Bracke

add size attribute to BarcodeCapture; make width/height of barcode capture non-null

... ... @@ -7,6 +7,8 @@ Improvements:
* The `phones` and `urls` of `ContactInfo` are now non-null.
* The `url` of a `UrlBookmark` is now non-null.
* The `type` of `Phone` is now non-null.
* The `width` and `height` of `BarcodeCapture` are now non-null.
* The `BarcodeCapture` class now exposes a `size`.
## 3.5.0
New Features:
... ...
import 'dart:typed_data';
import 'dart:ui';
import 'package:mobile_scanner/src/objects/barcode.dart';
/// The return object after a frame is scanned.
///
/// [barcodes] A list with barcodes. A scanned frame can contain multiple
/// barcodes.
/// [image] If enabled, an image of the scanned frame.
/// This class represents a scanned barcode.
class BarcodeCapture {
/// Create a new [BarcodeCapture] instance.
BarcodeCapture({
this.barcodes = const <Barcode>[],
double? height,
this.image,
this.raw,
double? width,
}) : size =
width == null && height == null ? Size.zero : Size(width!, height!);
/// The list of scanned barcodes.
final List<Barcode> barcodes;
final dynamic raw;
/// The bytes of the image that is embedded in the barcode.
///
/// This null if [MobileScannerController.returnImage] is false.
final Uint8List? image;
final double? width;
/// The raw data of the scanned barcode.
final dynamic raw; // TODO: this should be `Object?` instead of dynamic
final double? height;
/// The size of the scanned barcode.
final Size size;
BarcodeCapture({
required this.barcodes,
required this.raw,
this.image,
this.width,
this.height,
});
/// 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;
}
... ...