Navaron Bracke

move UrlBookmark to its own file

@@ -4,6 +4,7 @@ Improvements: @@ -4,6 +4,7 @@ Improvements:
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 * The `phones` and `urls` of `ContactInfo` are now non-null.
  7 +* The `url` of a `UrlBookmark` is now non-null.
7 8
8 ## 3.5.0 9 ## 3.5.0
9 New Features: 10 New Features:
@@ -21,4 +21,5 @@ export 'src/objects/email.dart'; @@ -21,4 +21,5 @@ export 'src/objects/email.dart';
21 export 'src/objects/geo_point.dart'; 21 export 'src/objects/geo_point.dart';
22 export 'src/objects/mobile_scanner_arguments.dart'; 22 export 'src/objects/mobile_scanner_arguments.dart';
23 export 'src/objects/sms.dart'; 23 export 'src/objects/sms.dart';
  24 +export 'src/objects/url_bookmark.dart';
24 export 'src/objects/wifi.dart'; 25 export 'src/objects/wifi.dart';
@@ -2,7 +2,6 @@ import 'dart:math' as math; @@ -2,7 +2,6 @@ import 'dart:math' as math;
2 2
3 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
4 import 'package:mobile_scanner/mobile_scanner.dart'; 4 import 'package:mobile_scanner/mobile_scanner.dart';
5 -import 'package:mobile_scanner/src/objects/geo_point.dart';  
6 5
7 Size toSize(Map data) { 6 Size toSize(Map data) {
8 final width = data['width'] as double; 7 final width = data['width'] as double;
@@ -12,6 +12,7 @@ import 'package:mobile_scanner/src/objects/driver_license.dart'; @@ -12,6 +12,7 @@ import 'package:mobile_scanner/src/objects/driver_license.dart';
12 import 'package:mobile_scanner/src/objects/email.dart'; 12 import 'package:mobile_scanner/src/objects/email.dart';
13 import 'package:mobile_scanner/src/objects/geo_point.dart'; 13 import 'package:mobile_scanner/src/objects/geo_point.dart';
14 import 'package:mobile_scanner/src/objects/sms.dart'; 14 import 'package:mobile_scanner/src/objects/sms.dart';
  15 +import 'package:mobile_scanner/src/objects/url_bookmark.dart';
15 import 'package:mobile_scanner/src/objects/wifi.dart'; 16 import 'package:mobile_scanner/src/objects/wifi.dart';
16 17
17 /// Represents a single recognized barcode and its value. 18 /// Represents a single recognized barcode and its value.
@@ -206,21 +207,3 @@ class Phone { @@ -206,21 +207,3 @@ class Phone {
206 : number = data['number'] as String?, 207 : number = data['number'] as String?,
207 type = PhoneType.values[data['type'] as int]; 208 type = PhoneType.values[data['type'] as int];
208 } 209 }
209 -  
210 -/// A URL and title from a 'MEBKM:' or similar QRCode type.  
211 -class UrlBookmark {  
212 - /// Gets the title of the bookmark.  
213 - ///  
214 - /// Returns null if not available.  
215 - final String? title;  
216 -  
217 - /// Gets the url of the bookmark.  
218 - ///  
219 - /// Returns null if not available.  
220 - final String? url;  
221 -  
222 - /// Create a [UrlBookmark] from native data.  
223 - UrlBookmark.fromNative(Map data)  
224 - : title = data['title'] as String?,  
225 - url = data['url'] as String?;  
226 -}  
  1 +/// A URL and title from a `MEBKM:` or similar QRCode type.
  2 +class UrlBookmark {
  3 + /// Construct a new [UrlBookmark] instance.
  4 + const UrlBookmark({
  5 + this.title,
  6 + required this.url,
  7 + });
  8 +
  9 + /// Construct a new [UrlBookmark] instance from the given [data].
  10 + factory UrlBookmark.fromNative(Map<Object?, Object?> data) {
  11 + return UrlBookmark(
  12 + title: data['title'] as String?,
  13 + url: data['url'] as String? ?? '',
  14 + );
  15 + }
  16 +
  17 + /// The title of the bookmark.
  18 + final String? title;
  19 +
  20 + /// The url of the bookmark.
  21 + final String url;
  22 +}