Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Review fixes
  • Loading branch information
stuartmorgan-g committed Feb 17, 2021
commit 41963c86310ad726644115d4673297ffb263c54c
4 changes: 4 additions & 0 deletions packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## 2.0.0-nullsafety

* Migrate to null-safety
* BREAKING CHANGE: Passing an unknown map object ID (e.g., MarkerId) to a
method, it will throw an `UnknownMapObjectIDError`. Previously it would
either silently do nothing, or throw an error trying to call a function on
`null`, depneding on the method.

## 1.2.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class ScrollingMapBody extends StatelessWidget {
target: center,
zoom: 11.0,
),
gestureRecognizers: <
Factory<OneSequenceGestureRecognizer>>{
gestureRecognizers: //
<Factory<OneSequenceGestureRecognizer>>{
Factory<OneSequenceGestureRecognizer>(
() => EagerGestureRecognizer(),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ typedef void MapCreatedCallback(GoogleMapController controller);
int _nextMapCreationId = 0;

/// Error thrown when an unknown map object ID is provided to a method.
class UnknownMapObjectIDError extends Error {
class UnknownMapObjectIdError extends Error {
/// Creates an assertion error with the provided [message].
UnknownMapObjectIDError(this.objectType, [this.context]);
UnknownMapObjectIdError(this.objectType, this.objectId, [this.context]);

/// The name of the map object whose ID is unknown.
final String objectType;

/// The unknown maps object ID.
final MapsObjectId objectId;

/// The context where the error occurred.
final String? context;

String toString() {
if (context != null) {
return "Unknown $objectType ID in $context";
return 'Unknown $objectType ID "${objectId.value}" in $context';
}
return "Unknown $objectType ID";
return 'Unknown $objectType ID "${objectId.value}"';
}
}

Expand Down Expand Up @@ -357,7 +360,7 @@ class _GoogleMapState extends State<GoogleMap> {
assert(markerId != null);
final Marker? marker = _markers[markerId];
if (marker == null) {
throw UnknownMapObjectIDError('marker', 'onTap');
throw UnknownMapObjectIdError('marker', markerId, 'onTap');
}
final onTap = marker.onTap;
if (onTap != null) {
Expand All @@ -369,7 +372,7 @@ class _GoogleMapState extends State<GoogleMap> {
assert(markerId != null);
final Marker? marker = _markers[markerId];
if (marker == null) {
throw UnknownMapObjectIDError('marker', 'onDragEnd');
throw UnknownMapObjectIdError('marker', markerId, 'onDragEnd');
}
final onDragEnd = marker.onDragEnd;
if (onDragEnd != null) {
Expand All @@ -381,7 +384,7 @@ class _GoogleMapState extends State<GoogleMap> {
assert(polygonId != null);
final Polygon? polygon = _polygons[polygonId];
if (polygon == null) {
throw UnknownMapObjectIDError('polygon', 'onTap');
throw UnknownMapObjectIdError('polygon', polygonId, 'onTap');
}
final onTap = polygon.onTap;
if (onTap != null) {
Expand All @@ -393,7 +396,7 @@ class _GoogleMapState extends State<GoogleMap> {
assert(polylineId != null);
final Polyline? polyline = _polylines[polylineId];
if (polyline == null) {
throw UnknownMapObjectIDError('polyline', 'onTap');
throw UnknownMapObjectIdError('polyline', polylineId, 'onTap');
}
final onTap = polyline.onTap;
if (onTap != null) {
Expand All @@ -405,7 +408,7 @@ class _GoogleMapState extends State<GoogleMap> {
assert(circleId != null);
final Circle? circle = _circles[circleId];
if (circle == null) {
throw UnknownMapObjectIDError('marker', 'onTap');
throw UnknownMapObjectIdError('marker', circleId, 'onTap');
}
final onTap = circle.onTap;
if (onTap != null) {
Expand All @@ -417,7 +420,7 @@ class _GoogleMapState extends State<GoogleMap> {
assert(markerId != null);
final Marker? marker = _markers[markerId];
if (marker == null) {
throw UnknownMapObjectIDError('marker', 'InfoWindow onTap');
throw UnknownMapObjectIdError('marker', markerId, 'InfoWindow onTap');
}
final onTap = marker.infoWindow.onTap;
if (onTap != null) {
Expand Down Expand Up @@ -462,9 +465,8 @@ class _GoogleMapOptions {
padding = map.padding,
indoorViewEnabled = map.indoorViewEnabled,
trafficEnabled = map.trafficEnabled,
buildingsEnabled = map.buildingsEnabled {
assert(!liteModeEnabled || Platform.isAndroid);
}
buildingsEnabled = map.buildingsEnabled,
assert(!map.liteModeEnabled || Platform.isAndroid);

final bool compassEnabled;

Expand Down