Navaron Bracke

add size to barcode

@@ -28,6 +28,7 @@ class Barcode { @@ -28,6 +28,7 @@ class Barcode {
28 this.phone, 28 this.phone,
29 this.rawBytes, 29 this.rawBytes,
30 this.rawValue, 30 this.rawValue,
  31 + this.size = Size.zero,
31 this.sms, 32 this.sms,
32 this.type = BarcodeType.unknown, 33 this.type = BarcodeType.unknown,
33 this.url, 34 this.url,
@@ -38,9 +39,9 @@ class Barcode { @@ -38,9 +39,9 @@ class Barcode {
38 factory Barcode.fromNative(Map<Object?, Object?> data) { 39 factory Barcode.fromNative(Map<Object?, Object?> data) {
39 final Map<Object?, Object?>? calendarEvent = 40 final Map<Object?, Object?>? calendarEvent =
40 data['calendarEvent'] as Map<Object?, Object?>?; 41 data['calendarEvent'] as Map<Object?, Object?>?;
41 - final List<Object?>? corners = data['corners'] as List<Object?>?;  
42 final Map<Object?, Object?>? contactInfo = 42 final Map<Object?, Object?>? contactInfo =
43 data['contactInfo'] as Map<Object?, Object?>?; 43 data['contactInfo'] as Map<Object?, Object?>?;
  44 + final List<Object?>? corners = data['corners'] as List<Object?>?;
44 final Map<Object?, Object?>? driverLicense = 45 final Map<Object?, Object?>? driverLicense =
45 data['driverLicense'] as Map<Object?, Object?>?; 46 data['driverLicense'] as Map<Object?, Object?>?;
46 final Map<Object?, Object?>? email = 47 final Map<Object?, Object?>? email =
@@ -50,9 +51,13 @@ class Barcode { @@ -50,9 +51,13 @@ class Barcode {
50 final Map<Object?, Object?>? phone = 51 final Map<Object?, Object?>? phone =
51 data['phone'] as Map<Object?, Object?>?; 52 data['phone'] as Map<Object?, Object?>?;
52 final Map<Object?, Object?>? sms = data['sms'] as Map<Object?, Object?>?; 53 final Map<Object?, Object?>? sms = data['sms'] as Map<Object?, Object?>?;
  54 + final Map<Object?, Object?>? size = data['size'] as Map<Object?, Object?>?;
53 final Map<Object?, Object?>? url = data['url'] as Map<Object?, Object?>?; 55 final Map<Object?, Object?>? url = data['url'] as Map<Object?, Object?>?;
54 final Map<Object?, Object?>? wifi = data['wifi'] as Map<Object?, Object?>?; 56 final Map<Object?, Object?>? wifi = data['wifi'] as Map<Object?, Object?>?;
55 57
  58 + final double? barcodeWidth = size?['width'] as double?;
  59 + final double? barcodeHeight = size?['height'] as double?;
  60 +
56 return Barcode( 61 return Barcode(
57 calendarEvent: calendarEvent == null 62 calendarEvent: calendarEvent == null
58 ? null 63 ? null
@@ -81,6 +86,9 @@ class Barcode { @@ -81,6 +86,9 @@ class Barcode {
81 phone: phone == null ? null : Phone.fromNative(phone), 86 phone: phone == null ? null : Phone.fromNative(phone),
82 rawBytes: data['rawBytes'] as Uint8List?, 87 rawBytes: data['rawBytes'] as Uint8List?,
83 rawValue: data['rawValue'] as String?, 88 rawValue: data['rawValue'] as String?,
  89 + size: barcodeWidth == null || barcodeHeight == null
  90 + ? Size.zero
  91 + : Size(barcodeWidth, barcodeHeight),
84 sms: sms == null ? null : SMS.fromNative(sms), 92 sms: sms == null ? null : SMS.fromNative(sms),
85 type: BarcodeType.fromRawValue(data['type'] as int? ?? 0), 93 type: BarcodeType.fromRawValue(data['type'] as int? ?? 0),
86 url: url == null ? null : UrlBookmark.fromNative(url), 94 url: url == null ? null : UrlBookmark.fromNative(url),
@@ -144,6 +152,11 @@ class Barcode { @@ -144,6 +152,11 @@ class Barcode {
144 /// This is null if the raw value is not available. 152 /// This is null if the raw value is not available.
145 final String? rawValue; 153 final String? rawValue;
146 154
  155 + /// The size of the barcode bounding box.
  156 + ///
  157 + /// If the bounding box is unavailable, this will be [Size.zero].
  158 + final Size size;
  159 +
147 /// The SMS message that is embedded in the barcode. 160 /// The SMS message that is embedded in the barcode.
148 final SMS? sms; 161 final SMS? sms;
149 162