Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Fix crash from null Google Maps object #4250

Merged
merged 7 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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