Showing
5 changed files
with
36 additions
and
19 deletions
| 1 | ## NEXT | 1 | ## NEXT |
| 2 | Improvements: | 2 | Improvements: |
| 3 | +* The `type` of an `Address` is now non-null. | ||
| 3 | * The `type` of an `Email` is now non-null. | 4 | * The `type` of an `Email` is now non-null. |
| 4 | * The `phoneNumber` of an `SMS` is now non-null. | 5 | * The `phoneNumber` of an `SMS` is now non-null. |
| 5 | * The `latitude` and `longitude` of a `GeoPoint` are now non-null. | 6 | * The `latitude` and `longitude` of a `GeoPoint` are now non-null. |
| @@ -12,6 +12,7 @@ export 'src/enums/torch_state.dart'; | @@ -12,6 +12,7 @@ export 'src/enums/torch_state.dart'; | ||
| 12 | export 'src/mobile_scanner.dart'; | 12 | export 'src/mobile_scanner.dart'; |
| 13 | export 'src/mobile_scanner_controller.dart'; | 13 | export 'src/mobile_scanner_controller.dart'; |
| 14 | export 'src/mobile_scanner_exception.dart'; | 14 | export 'src/mobile_scanner_exception.dart'; |
| 15 | +export 'src/objects/address.dart'; | ||
| 15 | export 'src/objects/barcode.dart'; | 16 | export 'src/objects/barcode.dart'; |
| 16 | export 'src/objects/barcode_capture.dart'; | 17 | export 'src/objects/barcode_capture.dart'; |
| 17 | export 'src/objects/calendar_event.dart'; | 18 | export 'src/objects/calendar_event.dart'; |
lib/src/objects/address.dart
0 → 100644
| 1 | +import 'package:mobile_scanner/src/enums/address_type.dart'; | ||
| 2 | + | ||
| 3 | +/// An address. | ||
| 4 | +class Address { | ||
| 5 | + /// Creates a new [Address] instance. | ||
| 6 | + const Address({ | ||
| 7 | + this.addressLines = const <String>[], | ||
| 8 | + this.type = AddressType.unknown, | ||
| 9 | + }); | ||
| 10 | + | ||
| 11 | + /// Creates a new [Address] instance from a map. | ||
| 12 | + factory Address.fromNative(Map<Object?, Object?> data) { | ||
| 13 | + final List<Object?>? addressLines = data['addressLines'] as List<Object?>?; | ||
| 14 | + final AddressType type = AddressType.fromRawValue( | ||
| 15 | + data['type'] as int? ?? 0, | ||
| 16 | + ); | ||
| 17 | + | ||
| 18 | + if (addressLines == null) { | ||
| 19 | + return Address(type: type); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + return Address( | ||
| 23 | + addressLines: List.unmodifiable(addressLines.cast<String>()), | ||
| 24 | + type: type, | ||
| 25 | + ); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + /// The address lines that represent this address. | ||
| 29 | + final List<String> addressLines; | ||
| 30 | + | ||
| 31 | + /// Gets type of the address. | ||
| 32 | + final AddressType type; | ||
| 33 | +} |
| @@ -2,7 +2,6 @@ import 'dart:typed_data'; | @@ -2,7 +2,6 @@ import 'dart:typed_data'; | ||
| 2 | import 'dart:ui'; | 2 | import 'dart:ui'; |
| 3 | 3 | ||
| 4 | import 'package:mobile_scanner/src/barcode_utility.dart'; | 4 | import 'package:mobile_scanner/src/barcode_utility.dart'; |
| 5 | -import 'package:mobile_scanner/src/enums/address_type.dart'; | ||
| 6 | import 'package:mobile_scanner/src/enums/barcode_format.dart'; | 5 | import 'package:mobile_scanner/src/enums/barcode_format.dart'; |
| 7 | import 'package:mobile_scanner/src/enums/barcode_type.dart'; | 6 | import 'package:mobile_scanner/src/enums/barcode_type.dart'; |
| 8 | import 'package:mobile_scanner/src/enums/phone_type.dart'; | 7 | import 'package:mobile_scanner/src/enums/phone_type.dart'; |
| @@ -123,24 +122,6 @@ class Barcode { | @@ -123,24 +122,6 @@ class Barcode { | ||
| 123 | wifi = toWiFi(data['wifi'] as Map?); | 122 | wifi = toWiFi(data['wifi'] as Map?); |
| 124 | } | 123 | } |
| 125 | 124 | ||
| 126 | -/// An address. | ||
| 127 | -class Address { | ||
| 128 | - /// Gets formatted address, multiple lines when appropriate. This field always contains at least one line. | ||
| 129 | - final List<String> addressLines; | ||
| 130 | - | ||
| 131 | - /// Gets type of the address. | ||
| 132 | - /// | ||
| 133 | - /// Returns null if not available. | ||
| 134 | - final AddressType? type; | ||
| 135 | - | ||
| 136 | - /// Create a [Address] from native data. | ||
| 137 | - Address.fromNative(Map data) | ||
| 138 | - : addressLines = List.unmodifiable( | ||
| 139 | - (data['addressLines'] as List? ?? []).cast<String>(), | ||
| 140 | - ), | ||
| 141 | - type = AddressType.values[data['type'] as int]; | ||
| 142 | -} | ||
| 143 | - | ||
| 144 | /// Phone number info. | 125 | /// Phone number info. |
| 145 | class Phone { | 126 | class Phone { |
| 146 | /// Gets phone number. | 127 | /// Gets phone number. |
| 1 | +import 'package:mobile_scanner/src/objects/address.dart'; | ||
| 1 | import 'package:mobile_scanner/src/objects/barcode.dart'; | 2 | import 'package:mobile_scanner/src/objects/barcode.dart'; |
| 2 | import 'package:mobile_scanner/src/objects/email.dart'; | 3 | import 'package:mobile_scanner/src/objects/email.dart'; |
| 3 | import 'package:mobile_scanner/src/objects/person_name.dart'; | 4 | import 'package:mobile_scanner/src/objects/person_name.dart'; |
-
Please register or login to post a comment