Skip to content

Commit

Permalink
Fix crash from null Google Maps object (flutter#4250)
Browse files Browse the repository at this point in the history
  • Loading branch information
bparrishMines authored Sep 15, 2021
1 parent 7fff936 commit 41cb992
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
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,3 +1,7 @@
## 2.0.9

* Fix Android `NullPointerException` caused by the `GoogleMapController` being disposed before `GoogleMap` was ready.

## 2.0.8

* Mark iOS arm64 simulators as unsupported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ final class GoogleMapController
private final MethodChannel methodChannel;
private final GoogleMapOptions options;
@Nullable private MapView mapView;
private GoogleMap googleMap;
@Nullable private GoogleMap googleMap;
private boolean trackCameraPosition = false;
private boolean myLocationEnabled = false;
private boolean myLocationButtonEnabled = false;
Expand Down Expand Up @@ -508,6 +508,10 @@ public void dispose() {
}

private void setGoogleMapListener(@Nullable GoogleMapListener listener) {
if (googleMap == null) {
Log.v(TAG, "Controller was disposed before GoogleMap was ready.");
return;
}
googleMap.setOnCameraMoveStartedListener(listener);
googleMap.setOnCameraMoveListener(listener);
googleMap.setOnCameraIdleListener(listener);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@

import androidx.test.core.app.ActivityScenario;
import io.flutter.plugins.googlemaps.GoogleMapsPlugin;
import org.junit.Ignore;
import org.junit.Test;

public class GoogleMapsTest {
@Ignore("Currently failing: https://github.com/flutter/flutter/issues/87566")
@Test
public void googleMapsPluginIsAdded() {
final ActivityScenario<GoogleMapsTestActivity> scenario =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: google_maps_flutter
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
repository: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter/google_maps_flutter
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
version: 2.0.8
version: 2.0.9

environment:
sdk: '>=2.12.0 <3.0.0'
Expand Down

0 comments on commit 41cb992

Please sign in to comment.