Skip to content

Commit d032edb

Browse files
committed
Changes timestamp to nullable
1 parent 04bf6f6 commit d032edb

File tree

11 files changed

+81
-58
lines changed

11 files changed

+81
-58
lines changed

geocoding_platform_interface/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 5.0.0
2+
3+
- **BREAKING CHANGES:**
4+
- Changes the `Location.timestamp` field to allow `null` values. Not all
5+
platforms (e.g. Android) specify a timestamp indicating when the
6+
coordinates for an address where resolved.
7+
18
## 4.0.0
29

310
- **BREAKING CHANGES:**

geocoding_platform_interface/analysis_options.yaml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,21 @@ include: package:flutter_lints/flutter.yaml
33
analyzer:
44
exclude:
55
# Ignore generated files
6-
- '**/*.g.dart'
7-
- 'lib/src/generated/*.dart'
6+
- "**/*.g.dart"
7+
- "lib/src/generated/*.dart"
88
linter:
99
rules:
10-
- public_member_api_docs
10+
- always_declare_return_types
11+
- always_put_control_body_on_new_line
12+
- always_specify_types
13+
- avoid_bool_literals_in_conditional_expressions
14+
- avoid_void_async
15+
- directives_ordering
16+
- eol_at_end_of_file
17+
- exhaustive_cases
18+
- prefer_final_in_for_each
19+
- prefer_final_locals
20+
- prefer_relative_imports
21+
- public_member_api_docs
22+
- require_trailing_commas
23+
- unawaited_futures

geocoding_platform_interface/lib/legacy/src/models/location.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Location {
5555
}
5656

5757
final Map<dynamic, dynamic> locationMap = message;
58-
final timestamp = DateTime.fromMillisecondsSinceEpoch(
58+
final DateTime timestamp = DateTime.fromMillisecondsSinceEpoch(
5959
locationMap['timestamp'].toInt(),
6060
isUtc: true,
6161
);
@@ -75,7 +75,7 @@ class Location {
7575

7676
/// Converts the [Location] instance into a [Map] instance that can be
7777
/// serialized to JSON.
78-
Map<String, dynamic> toJson() => {
78+
Map<String, dynamic> toJson() => <String, dynamic>{
7979
'latitude': latitude,
8080
'longitude': longitude,
8181
'timestamp': timestamp.millisecondsSinceEpoch,

geocoding_platform_interface/lib/legacy/src/models/placemark.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class Placemark {
131131

132132
/// Converts the [Placemark] instance into a [Map] instance that can be
133133
/// serialized to JSON.
134-
Map<String, dynamic> toJson() => {
134+
Map<String, dynamic> toJson() => <String, dynamic>{
135135
'name': name,
136136
'street': street,
137137
'isoCountryCode': isoCountryCode,

geocoding_platform_interface/lib/src/types/location.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Location {
1010
const Location({
1111
required this.latitude,
1212
required this.longitude,
13-
required this.timestamp,
13+
this.timestamp,
1414
});
1515

1616
/// The latitude associated with the placemark.
@@ -20,7 +20,10 @@ class Location {
2020
final double longitude;
2121

2222
/// The UTC timestamp the coordinates have been requested.
23-
final DateTime timestamp;
23+
///
24+
/// If `null`, the time the coordinates have been determined is not known or
25+
/// not provided by the platform (e.g. on Android).
26+
final DateTime? timestamp;
2427

2528
@override
2629
bool operator ==(Object other) =>

geocoding_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A common platform interface for the geocoding plugin.
33
homepage: https://github.com/baseflow/flutter-geocoding/tree/main/geocoding_platform_interface
44
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
55
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
6-
version: 4.0.0
6+
version: 5.0.0
77

88
environment:
99
sdk: ^3.8.1

geocoding_platform_interface/test/legacy/geocoding_platform_interface_test.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void main() {
3333
});
3434

3535
test('Can be mocked with `implements`', () {
36-
final mock = MockGeocodingPlatform();
36+
final MockGeocodingPlatform mock = MockGeocodingPlatform();
3737
GeocodingPlatform.instance = mock;
3838
});
3939

@@ -42,7 +42,7 @@ void main() {
4242
'Default implementation of locationFromAddress should throw unimplemented error',
4343
() {
4444
// Arrange
45-
final geocodingPlatform = ExtendsGeocodingPlatform();
45+
final ExtendsGeocodingPlatform geocodingPlatform = ExtendsGeocodingPlatform();
4646

4747
// Act & Assert
4848
expect(
@@ -57,7 +57,7 @@ void main() {
5757
'Default implementation of isPresent should throw unimplemented error',
5858
() {
5959
// Arrange
60-
final geocodingPlatform = ExtendsGeocodingPlatform();
60+
final ExtendsGeocodingPlatform geocodingPlatform = ExtendsGeocodingPlatform();
6161

6262
// Act & Assert
6363
expect(() => geocodingPlatform.isPresent(), throwsUnimplementedError);
@@ -69,7 +69,7 @@ void main() {
6969
'Default implementation of placemarkFromCoordinates should throw unimplemented error',
7070
() {
7171
// Arrange
72-
final geocodingPlatform = ExtendsGeocodingPlatform();
72+
final ExtendsGeocodingPlatform geocodingPlatform = ExtendsGeocodingPlatform();
7373

7474
// Act & Assert
7575
expect(
@@ -84,7 +84,7 @@ void main() {
8484
'Default implementation of setLocale should throw unimplemented error',
8585
() {
8686
// Arrange
87-
final geocodingPlatform = ExtendsGeocodingPlatform();
87+
final ExtendsGeocodingPlatform geocodingPlatform = ExtendsGeocodingPlatform();
8888

8989
// Act & Assert
9090
expect(

geocoding_platform_interface/test/legacy/src/models/location_test.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ void main() {
77
'hashCode hould be the same for two instances with the same values',
88
() {
99
// Arrange
10-
final firstLocation = Location(
10+
final Location firstLocation = Location(
1111
latitude: 0,
1212
longitude: 0,
1313
timestamp: DateTime.fromMillisecondsSinceEpoch((0)),
1414
);
15-
final secondLocation = Location(
15+
final Location secondLocation = Location(
1616
latitude: 0,
1717
longitude: 0,
1818
timestamp: DateTime.fromMillisecondsSinceEpoch((0)),
@@ -27,12 +27,12 @@ void main() {
2727
'hashCode should not match when the latitude property is different',
2828
() {
2929
// Arrange
30-
final firstLocation = Location(
30+
final Location firstLocation = Location(
3131
latitude: 0,
3232
longitude: 0,
3333
timestamp: DateTime.fromMillisecondsSinceEpoch(0),
3434
);
35-
final secondLocation = Location(
35+
final Location secondLocation = Location(
3636
latitude: 1,
3737
longitude: 0,
3838
timestamp: DateTime.fromMillisecondsSinceEpoch(0),
@@ -47,12 +47,12 @@ void main() {
4747
'hashCode should not match when the longitude property is different',
4848
() {
4949
// Arrange
50-
final firstLocation = Location(
50+
final Location firstLocation = Location(
5151
latitude: 0,
5252
longitude: 0,
5353
timestamp: DateTime.fromMillisecondsSinceEpoch(0),
5454
);
55-
final secondLocation = Location(
55+
final Location secondLocation = Location(
5656
latitude: 0,
5757
longitude: 1,
5858
timestamp: DateTime.fromMillisecondsSinceEpoch(0),
@@ -67,12 +67,12 @@ void main() {
6767
'hashCode should not match when the timestamp property is different',
6868
() {
6969
// Arrange
70-
final firstLocation = Location(
70+
final Location firstLocation = Location(
7171
latitude: 0,
7272
longitude: 0,
7373
timestamp: DateTime.fromMillisecondsSinceEpoch(0),
7474
);
75-
final secondLocation = Location(
75+
final Location secondLocation = Location(
7676
latitude: 0,
7777
longitude: 0,
7878
timestamp: DateTime.fromMillisecondsSinceEpoch(1),
@@ -92,7 +92,7 @@ void main() {
9292
test(
9393
'fromMap throws argument error when latitude or longitude are null',
9494
() {
95-
final location = <dynamic, dynamic>{
95+
final Map<dynamic, dynamic> location = <dynamic, dynamic>{
9696
'latitude': null,
9797
'longitude': null,
9898
'timestamp': 1615216821218,
@@ -104,13 +104,13 @@ void main() {
104104

105105
group('toString tests:', () {
106106
test('toString should list the contents of all properties', () {
107-
final mockLocation = Location(
107+
final Location mockLocation = Location(
108108
latitude: 52.2165157,
109109
longitude: 6.9437819,
110110
timestamp: DateTime.fromMillisecondsSinceEpoch(0).toUtc(),
111111
);
112112

113-
final expected =
113+
final String expected =
114114
'''
115115
Latitude: ${mockLocation.latitude},
116116
Longitude: ${mockLocation.longitude},

0 commit comments

Comments
 (0)