Navaron Bracke

move GeoPoint to its own file

... ... @@ -2,6 +2,7 @@
Improvements:
* The `type` of an `Email` is now non-null.
* The `phoneNumber` of an `SMS` is now non-null.
* The `latitude` and `longitude` of a `GeoPoint` are now non-null.
## 3.5.0
New Features:
... ...
... ... @@ -17,6 +17,7 @@ export 'src/objects/barcode_capture.dart';
export 'src/objects/calendar_event.dart';
export 'src/objects/driver_license.dart';
export 'src/objects/email.dart';
export 'src/objects/geo_point.dart';
export 'src/objects/mobile_scanner_arguments.dart';
export 'src/objects/sms.dart';
export 'src/objects/wifi.dart';
... ...
... ... @@ -2,6 +2,7 @@ import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:mobile_scanner/src/objects/geo_point.dart';
Size toSize(Map data) {
final width = data['width'] as double;
... ...
... ... @@ -9,6 +9,7 @@ import 'package:mobile_scanner/src/enums/phone_type.dart';
import 'package:mobile_scanner/src/objects/calendar_event.dart';
import 'package:mobile_scanner/src/objects/driver_license.dart';
import 'package:mobile_scanner/src/objects/email.dart';
import 'package:mobile_scanner/src/objects/geo_point.dart';
import 'package:mobile_scanner/src/objects/sms.dart';
import 'package:mobile_scanner/src/objects/wifi.dart';
... ... @@ -242,20 +243,6 @@ class PersonName {
pronunciation = data['pronunciation'] as String?;
}
/// GPS coordinates from a 'GEO:' or similar QRCode type.
class GeoPoint {
/// Gets the latitude.
final double? latitude;
/// Gets the longitude.
final double? longitude;
/// Create a [GeoPoint] from native data.
GeoPoint.fromNative(Map data)
: latitude = data['latitude'] as double?,
longitude = data['longitude'] as double?;
}
/// Phone number info.
class Phone {
/// Gets phone number.
... ...
/// GPS coordinates from a `GEO:` or similar QRCode type.
class GeoPoint {
/// Construct a new [GeoPoint] instance.
const GeoPoint({
required this.latitude,
required this.longitude,
});
/// Construct a [GeoPoint] from the given [data].
///
/// If the data does not contain valid GeoPoint coordinates,
/// then `0,0` is returned.
factory GeoPoint.fromNative(Map<Object?, Object?> data) {
final double? latitude = data['latitude'] as double?;
final double? longitude = data['longitude'] as double?;
// If either is not set, then this GeoPoint is invalid.
// Return the geographic center as fallback.
if (latitude == null || longitude == null) {
return const GeoPoint(latitude: 0.0, longitude: 0.0);
}
return GeoPoint(latitude: latitude, longitude: longitude);
}
/// The latitude of the coordinate.
final double latitude;
/// The longitude of the coordinate.
final double longitude;
}
... ...