Skip to content

Commit

Permalink
[google_maps_flutter] Avoid AbstractMethod crash (flutter#2113)
Browse files Browse the repository at this point in the history
Override a default method to work around flutter/flutter#40126. The root
cause of the issue has already been fixed in master and there is a
potential workaround available to apps already, but this is an extra
low-risk change that should prevent the crash for any affected users
while the fix is still rolling out to stable.
  • Loading branch information
Michael Klimushyn authored and Park Sung Min committed Dec 17, 2019
1 parent 3053052 commit 050bdb5
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/google_maps_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.21+6

* Override a default method to work around flutter/flutter#40126.

## 0.5.21+5

* Update and migrate iOS example project.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,20 @@ public void dispose() {
registrar.activity().getApplication().unregisterActivityLifecycleCallbacks(this);
}

// @Override
// The minimum supported version of Flutter doesn't have this method on the PlatformView interface, but the maximum
// does. This will override it when available even with the annotation commented out.
public void onInputConnectionLocked() {
// TODO(mklim): Remove this empty override once https://github.com/flutter/flutter/issues/40126 is fixed in stable.
};

// @Override
// The minimum supported version of Flutter doesn't have this method on the PlatformView interface, but the maximum
// does. This will override it when available even with the annotation commented out.
public void onInputConnectionUnlocked() {
// TODO(mklim): Remove this empty override once https://github.com/flutter/flutter/issues/40126 is fixed in stable.
};

@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
if (disposed || activity.hashCode() != registrarActivityHashCode) {
Expand Down
2 changes: 1 addition & 1 deletion packages/google_maps_flutter/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.5.0'
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip
37 changes: 37 additions & 0 deletions packages/google_maps_flutter/example/test_driver/google_maps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_driver/driver_extension.dart';
import 'package:flutter_test/flutter_test.dart';
Expand Down Expand Up @@ -638,4 +639,40 @@ void main() {

expect(topLeft, const ScreenCoordinate(x: 0, y: 0));
});

test('testResizeWidget', () async {
final Completer<GoogleMapController> controllerCompleter =
Completer<GoogleMapController>();
final GoogleMap map = GoogleMap(
initialCameraPosition: _kInitialCameraPosition,
onMapCreated: (GoogleMapController controller) async {
controllerCompleter.complete(controller);
},
);
await pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: MaterialApp(
home: Scaffold(
body: SizedBox(height: 100, width: 100, child: map)))));
final GoogleMapController controller = await controllerCompleter.future;

await pumpWidget(Directionality(
textDirection: TextDirection.ltr,
child: MaterialApp(
home: Scaffold(
body: SizedBox(height: 400, width: 400, child: map)))));

// We suspected a bug in the iOS Google Maps SDK caused the camera is not properly positioned at
// initialization. https://github.com/flutter/flutter/issues/24806
// This temporary workaround fix is provided while the actual fix in the Google Maps SDK is
// still being investigated.
// TODO(cyanglaz): Remove this temporary fix once the Maps SDK issue is resolved.
// https://github.com/flutter/flutter/issues/27550
await Future<dynamic>.delayed(const Duration(seconds: 3));

// Simple call to make sure that the app hasn't crashed.
final LatLngBounds bounds1 = await controller.getVisibleRegion();
final LatLngBounds bounds2 = await controller.getVisibleRegion();
expect(bounds1, bounds2);
});
}
2 changes: 1 addition & 1 deletion packages/google_maps_flutter/pubspec.yaml
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.
author: Flutter Team <flutter-dev@googlegroups.com>
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter
version: 0.5.21+5
version: 0.5.21+6

dependencies:
flutter:
Expand Down

0 comments on commit 050bdb5

Please sign in to comment.