diff --git a/geolocator_platform_interface/CHANGELOG.md b/geolocator_platform_interface/CHANGELOG.md index fb4ff66b..eb5ffe5d 100644 --- a/geolocator_platform_interface/CHANGELOG.md +++ b/geolocator_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.2.0 + +- Replaces an optional DateTime? `timestamp` in `Position` object for an NonNull DateTime `timestamp`. + ## 4.1.1 - Updates dependencies to latest versions to prevent conflicts with other packages. diff --git a/geolocator_platform_interface/lib/src/models/position.dart b/geolocator_platform_interface/lib/src/models/position.dart index 5fdf1566..d6a49141 100644 --- a/geolocator_platform_interface/lib/src/models/position.dart +++ b/geolocator_platform_interface/lib/src/models/position.dart @@ -30,7 +30,7 @@ class Position { final double longitude; /// The time at which this position was determined. - final DateTime? timestamp; + final DateTime timestamp; /// The altitude of the device in meters. /// @@ -141,10 +141,9 @@ class Position { 'The supplied map doesn\'t contain the mandatory key `longitude`.'); } - final timestamp = positionMap['timestamp'] != null - ? DateTime.fromMillisecondsSinceEpoch(positionMap['timestamp'].toInt(), - isUtc: true) - : null; + final timestamp = DateTime.fromMillisecondsSinceEpoch( + positionMap['timestamp'].toInt(), + isUtc: true); return Position( latitude: positionMap['latitude'], @@ -167,7 +166,7 @@ class Position { Map toJson() => { 'longitude': longitude, 'latitude': latitude, - 'timestamp': timestamp?.millisecondsSinceEpoch, + 'timestamp': timestamp.millisecondsSinceEpoch, 'accuracy': accuracy, 'altitude': altitude, 'altitude_accuracy': altitudeAccuracy, diff --git a/geolocator_platform_interface/pubspec.yaml b/geolocator_platform_interface/pubspec.yaml index 82489c08..efb3104c 100644 --- a/geolocator_platform_interface/pubspec.yaml +++ b/geolocator_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ description: A common platform interface for the geolocator plugin. repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 4.1.1 +version: 4.2.0 dependencies: flutter: