-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[google_maps_flutter] Migrate to NNBD #3548
Changes from 22 commits
8ad7f8f
74af2db
31f3487
675c88f
40b9700
0afb179
f7a1a66
54663a1
70f47f7
f08ab99
7c0a00c
55dcb8a
9afdc93
b60eee9
b5d4514
05089e8
8dc2ae2
99c36f3
ede5244
6bc0a2f
41963c8
a5598a9
77a1348
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,9 @@ class _MapClickBody extends StatefulWidget { | |
class _MapClickBodyState extends State<_MapClickBody> { | ||
_MapClickBodyState(); | ||
|
||
GoogleMapController mapController; | ||
LatLng _lastTap; | ||
LatLng _lastLongPress; | ||
GoogleMapController? mapController; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be late similar to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I went back and took a closer look at the I think it's not ideal that there are at least three different patterns for handling the async construction in these example files, but don't want to make changing that part of nullability migration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah I see. Yeah, I didn't have that context. Thanks |
||
LatLng? _lastTap; | ||
LatLng? _lastLongPress; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ class _MapCoordinatesBody extends StatefulWidget { | |
class _MapCoordinatesBodyState extends State<_MapCoordinatesBody> { | ||
_MapCoordinatesBodyState(); | ||
|
||
GoogleMapController mapController; | ||
GoogleMapController? mapController; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto: in some cases, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See other comment; this is correct. |
||
LatLngBounds _visibleRegion = LatLngBounds( | ||
southwest: const LatLng(0, 0), | ||
northeast: const LatLng(0, 0), | ||
|
@@ -87,7 +87,7 @@ class _MapCoordinatesBodyState extends State<_MapCoordinatesBody> { | |
child: const Text('Get Visible Region Bounds'), | ||
onPressed: () async { | ||
final LatLngBounds visibleRegion = | ||
await mapController.getVisibleRegion(); | ||
await mapController!.getVisibleRegion(); | ||
setState(() { | ||
_visibleRegion = visibleRegion; | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,8 @@ class MarkerIconsBody extends StatefulWidget { | |
const LatLng _kMapCenter = LatLng(52.4478, -3.5402); | ||
|
||
class MarkerIconsBodyState extends State<MarkerIconsBody> { | ||
GoogleMapController controller; | ||
BitmapDescriptor _markerIcon; | ||
GoogleMapController? controller; | ||
BitmapDescriptor? _markerIcon; | ||
Comment on lines
+32
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are flows in the existing logic that assume _markerIcon can be null. |
||
|
||
@override | ||
Widget build(BuildContext context) { | ||
|
@@ -48,7 +48,7 @@ class MarkerIconsBodyState extends State<MarkerIconsBody> { | |
target: _kMapCenter, | ||
zoom: 7.0, | ||
), | ||
markers: _createMarker(), | ||
markers: <Marker>{_createMarker()}, | ||
onMapCreated: _onMapCreated, | ||
), | ||
), | ||
|
@@ -57,17 +57,19 @@ class MarkerIconsBodyState extends State<MarkerIconsBody> { | |
); | ||
} | ||
|
||
Set<Marker> _createMarker() { | ||
// TODO(iskakaushik): Remove this when collection literals makes it to stable. | ||
// https://github.com/flutter/flutter/issues/28312 | ||
// ignore: prefer_collection_literals | ||
return <Marker>[ | ||
Marker( | ||
Marker _createMarker() { | ||
if (_markerIcon != null) { | ||
return Marker( | ||
markerId: MarkerId("marker_1"), | ||
position: _kMapCenter, | ||
icon: _markerIcon, | ||
), | ||
].toSet(); | ||
icon: _markerIcon!, | ||
); | ||
} else { | ||
return Marker( | ||
markerId: MarkerId("marker_1"), | ||
position: _kMapCenter, | ||
); | ||
} | ||
} | ||
|
||
Future<void> _createMarkerImageFromAsset(BuildContext context) async { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: assert size before reading the 2nd element
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While updating these I decided it wasn't worth adding complexity to the test code to assert incremental steps; if toJson returns a one-element array this test will fail with an out-of-bounds index exception, which gives us the same information than a length check would give us.
(The bigger problem is that this is testing code from the interface package; this test doesn't belong here at all. But moving it was out of scope for this change.)