Skip to content

Commit

Permalink
[platform_interface] 1145 removed optional timestamp (#1362)
Browse files Browse the repository at this point in the history
* removed optional timestamp

* Changed changelog text

* Removed accidental committed generated_plugins.cmake

* changed platform interface version

* Update CHANGELOG.md
  • Loading branch information
TimHoogstrate committed Nov 6, 2023
1 parent c994ce6 commit 5b07c28
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 4 additions & 0 deletions geolocator_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
11 changes: 5 additions & 6 deletions geolocator_platform_interface/lib/src/models/position.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -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'],
Expand All @@ -167,7 +166,7 @@ class Position {
Map<String, dynamic> toJson() => {
'longitude': longitude,
'latitude': latitude,
'timestamp': timestamp?.millisecondsSinceEpoch,
'timestamp': timestamp.millisecondsSinceEpoch,
'accuracy': accuracy,
'altitude': altitude,
'altitude_accuracy': altitudeAccuracy,
Expand Down
2 changes: 1 addition & 1 deletion geolocator_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 5b07c28

Please sign in to comment.