Showing
4 changed files
with
74 additions
and
56 deletions
| @@ -3,6 +3,7 @@ Improvements: | @@ -3,6 +3,7 @@ Improvements: | ||
| 3 | * The `type` of an `Email` is now non-null. | 3 | * The `type` of an `Email` is now non-null. |
| 4 | * The `phoneNumber` of an `SMS` is now non-null. | 4 | * The `phoneNumber` of an `SMS` is now non-null. |
| 5 | * The `latitude` and `longitude` of a `GeoPoint` are now non-null. | 5 | * The `latitude` and `longitude` of a `GeoPoint` are now non-null. |
| 6 | +* The `phones` and `urls` of `ContactInfo` are now non-null. | ||
| 6 | 7 | ||
| 7 | ## 3.5.0 | 8 | ## 3.5.0 |
| 8 | New Features: | 9 | New Features: |
| @@ -15,6 +15,7 @@ export 'src/mobile_scanner_exception.dart'; | @@ -15,6 +15,7 @@ export 'src/mobile_scanner_exception.dart'; | ||
| 15 | export 'src/objects/barcode.dart'; | 15 | export 'src/objects/barcode.dart'; |
| 16 | export 'src/objects/barcode_capture.dart'; | 16 | export 'src/objects/barcode_capture.dart'; |
| 17 | export 'src/objects/calendar_event.dart'; | 17 | export 'src/objects/calendar_event.dart'; |
| 18 | +export 'src/objects/contact_info.dart'; | ||
| 18 | export 'src/objects/driver_license.dart'; | 19 | export 'src/objects/driver_license.dart'; |
| 19 | export 'src/objects/email.dart'; | 20 | export 'src/objects/email.dart'; |
| 20 | export 'src/objects/geo_point.dart'; | 21 | export 'src/objects/geo_point.dart'; |
| @@ -7,6 +7,7 @@ import 'package:mobile_scanner/src/enums/barcode_format.dart'; | @@ -7,6 +7,7 @@ import 'package:mobile_scanner/src/enums/barcode_format.dart'; | ||
| 7 | import 'package:mobile_scanner/src/enums/barcode_type.dart'; | 7 | import 'package:mobile_scanner/src/enums/barcode_type.dart'; |
| 8 | import 'package:mobile_scanner/src/enums/phone_type.dart'; | 8 | import 'package:mobile_scanner/src/enums/phone_type.dart'; |
| 9 | import 'package:mobile_scanner/src/objects/calendar_event.dart'; | 9 | import 'package:mobile_scanner/src/objects/calendar_event.dart'; |
| 10 | +import 'package:mobile_scanner/src/objects/contact_info.dart'; | ||
| 10 | import 'package:mobile_scanner/src/objects/driver_license.dart'; | 11 | import 'package:mobile_scanner/src/objects/driver_license.dart'; |
| 11 | import 'package:mobile_scanner/src/objects/email.dart'; | 12 | import 'package:mobile_scanner/src/objects/email.dart'; |
| 12 | import 'package:mobile_scanner/src/objects/geo_point.dart'; | 13 | import 'package:mobile_scanner/src/objects/geo_point.dart'; |
| @@ -121,62 +122,6 @@ class Barcode { | @@ -121,62 +122,6 @@ class Barcode { | ||
| 121 | wifi = toWiFi(data['wifi'] as Map?); | 122 | wifi = toWiFi(data['wifi'] as Map?); |
| 122 | } | 123 | } |
| 123 | 124 | ||
| 124 | -/// A person's or organization's business card. For example a VCARD. | ||
| 125 | -class ContactInfo { | ||
| 126 | - /// Gets contact person's addresses. | ||
| 127 | - /// | ||
| 128 | - /// Returns an empty list if nothing found. | ||
| 129 | - final List<Address> addresses; | ||
| 130 | - | ||
| 131 | - /// Gets contact person's emails. | ||
| 132 | - /// | ||
| 133 | - /// Returns an empty list if nothing found. | ||
| 134 | - final List<Email> emails; | ||
| 135 | - | ||
| 136 | - /// Gets contact person's name. | ||
| 137 | - /// | ||
| 138 | - /// Returns null if not available. | ||
| 139 | - final PersonName? name; | ||
| 140 | - | ||
| 141 | - /// Gets contact person's organization. | ||
| 142 | - /// | ||
| 143 | - /// Returns null if not available. | ||
| 144 | - final String? organization; | ||
| 145 | - | ||
| 146 | - /// Gets contact person's phones. | ||
| 147 | - /// | ||
| 148 | - /// Returns an empty list if nothing found. | ||
| 149 | - final List<Phone>? phones; | ||
| 150 | - | ||
| 151 | - /// Gets contact person's title. | ||
| 152 | - /// | ||
| 153 | - /// Returns null if not available. | ||
| 154 | - final String? title; | ||
| 155 | - | ||
| 156 | - /// Gets contact person's urls. | ||
| 157 | - /// | ||
| 158 | - /// Returns an empty list if nothing found. | ||
| 159 | - final List<String>? urls; | ||
| 160 | - | ||
| 161 | - /// Create a [ContactInfo] from native data. | ||
| 162 | - ContactInfo.fromNative(Map data) | ||
| 163 | - : addresses = List.unmodifiable( | ||
| 164 | - (data['addresses'] as List? ?? []) | ||
| 165 | - .cast<Map>() | ||
| 166 | - .map(Address.fromNative), | ||
| 167 | - ), | ||
| 168 | - emails = List.unmodifiable( | ||
| 169 | - (data['emails'] as List? ?? []).cast<Map>().map(Email.fromNative), | ||
| 170 | - ), | ||
| 171 | - name = toName(data['name'] as Map?), | ||
| 172 | - organization = data['organization'] as String?, | ||
| 173 | - phones = List.unmodifiable( | ||
| 174 | - (data['phones'] as List? ?? []).cast<Map>().map(Phone.fromNative), | ||
| 175 | - ), | ||
| 176 | - title = data['title'] as String?, | ||
| 177 | - urls = List.unmodifiable((data['urls'] as List? ?? []).cast<String>()); | ||
| 178 | -} | ||
| 179 | - | ||
| 180 | /// An address. | 125 | /// An address. |
| 181 | class Address { | 126 | class Address { |
| 182 | /// Gets formatted address, multiple lines when appropriate. This field always contains at least one line. | 127 | /// Gets formatted address, multiple lines when appropriate. This field always contains at least one line. |
lib/src/objects/contact_info.dart
0 → 100644
| 1 | +import 'package:mobile_scanner/src/objects/barcode.dart'; | ||
| 2 | +import 'package:mobile_scanner/src/objects/email.dart'; | ||
| 3 | + | ||
| 4 | +/// A person's or organization's business card. | ||
| 5 | +/// For example a VCARD. | ||
| 6 | +class ContactInfo { | ||
| 7 | + /// Create a new [ContactInfo] instance. | ||
| 8 | + const ContactInfo({ | ||
| 9 | + this.addresses = const <Address>[], | ||
| 10 | + this.emails = const <Email>[], | ||
| 11 | + this.name, | ||
| 12 | + this.organization, | ||
| 13 | + this.phones = const <Phone>[], | ||
| 14 | + this.title, | ||
| 15 | + this.urls = const <String>[], | ||
| 16 | + }); | ||
| 17 | + | ||
| 18 | + /// Create a new [ContactInfo] instance from a map. | ||
| 19 | + factory ContactInfo.fromNative(Map<Object?, Object?> data) { | ||
| 20 | + final List<Object?>? addresses = data['addresses'] as List<Object?>?; | ||
| 21 | + final List<Object?>? emails = data['emails'] as List<Object?>?; | ||
| 22 | + final List<Object?>? phones = data['phones'] as List<Object?>?; | ||
| 23 | + final List<Object?>? urls = data['urls'] as List<Object?>?; | ||
| 24 | + final Map<Object?, Object?>? name = data['name'] as Map<Object?, Object?>?; | ||
| 25 | + | ||
| 26 | + return ContactInfo( | ||
| 27 | + addresses: addresses == null | ||
| 28 | + ? const <Address>[] | ||
| 29 | + : List.unmodifiable( | ||
| 30 | + addresses.cast<Map<Object?, Object?>>().map(Address.fromNative), | ||
| 31 | + ), | ||
| 32 | + emails: emails == null | ||
| 33 | + ? const <Email>[] | ||
| 34 | + : List.unmodifiable( | ||
| 35 | + emails.cast<Map<Object?, Object?>>().map(Email.fromNative), | ||
| 36 | + ), | ||
| 37 | + name: name == null ? null : PersonName.fromNative(name), | ||
| 38 | + organization: data['organization'] as String?, | ||
| 39 | + phones: phones == null | ||
| 40 | + ? const <Phone>[] | ||
| 41 | + : List.unmodifiable( | ||
| 42 | + phones.cast<Map<Object?, Object?>>().map(Phone.fromNative), | ||
| 43 | + ), | ||
| 44 | + title: data['title'] as String?, | ||
| 45 | + urls: urls == null | ||
| 46 | + ? const <String>[] | ||
| 47 | + : List.unmodifiable(urls.cast<String>()), | ||
| 48 | + ); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /// The list of addresses for the person or organisation. | ||
| 52 | + final List<Address> addresses; | ||
| 53 | + | ||
| 54 | + /// The list of email addresses for the person or organisation. | ||
| 55 | + final List<Email> emails; | ||
| 56 | + | ||
| 57 | + /// The name of the contact person. | ||
| 58 | + final PersonName? name; | ||
| 59 | + | ||
| 60 | + /// The name of the organization. | ||
| 61 | + final String? organization; | ||
| 62 | + | ||
| 63 | + /// The available phone numbers for the contact person or organisation. | ||
| 64 | + final List<Phone> phones; | ||
| 65 | + | ||
| 66 | + /// The contact person's title. | ||
| 67 | + final String? title; | ||
| 68 | + | ||
| 69 | + /// The urls associated with the contact person or organisation. | ||
| 70 | + final List<String> urls; | ||
| 71 | +} |
-
Please register or login to post a comment