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

Commit a00be1f

Browse files
author
Michael Klimushyn
authored
[google_maps_flutter] Avoid AbstractMethod crash (#2113)
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.
1 parent 4e12eb2 commit a00be1f

File tree

7 files changed

+59
-3
lines changed

7 files changed

+59
-3
lines changed

packages/google_maps_flutter/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.21+6
2+
3+
* Override a default method to work around flutter/flutter#40126.
4+
15
## 0.5.21+5
26

37
* Update and migrate iOS example project.

packages/google_maps_flutter/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapController.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,20 @@ public void dispose() {
468468
registrar.activity().getApplication().unregisterActivityLifecycleCallbacks(this);
469469
}
470470

471+
// @Override
472+
// The minimum supported version of Flutter doesn't have this method on the PlatformView interface, but the maximum
473+
// does. This will override it when available even with the annotation commented out.
474+
public void onInputConnectionLocked() {
475+
// TODO(mklim): Remove this empty override once https://github.com/flutter/flutter/issues/40126 is fixed in stable.
476+
};
477+
478+
// @Override
479+
// The minimum supported version of Flutter doesn't have this method on the PlatformView interface, but the maximum
480+
// does. This will override it when available even with the annotation commented out.
481+
public void onInputConnectionUnlocked() {
482+
// TODO(mklim): Remove this empty override once https://github.com/flutter/flutter/issues/40126 is fixed in stable.
483+
};
484+
471485
@Override
472486
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
473487
if (disposed || activity.hashCode() != registrarActivityHashCode) {

packages/google_maps_flutter/example/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.3.2'
8+
classpath 'com.android.tools.build:gradle:3.5.0'
99
}
1010
}
1111

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
org.gradle.jvmargs=-Xmx1536M
2+
android.enableR8=true

packages/google_maps_flutter/example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip

packages/google_maps_flutter/example/test_driver/google_maps.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import 'dart:async';
66
import 'dart:io';
77

8+
import 'package:flutter/material.dart';
89
import 'package:flutter/widgets.dart';
910
import 'package:flutter_driver/driver_extension.dart';
1011
import 'package:flutter_test/flutter_test.dart';
@@ -638,4 +639,40 @@ void main() {
638639

639640
expect(topLeft, const ScreenCoordinate(x: 0, y: 0));
640641
});
642+
643+
test('testResizeWidget', () async {
644+
final Completer<GoogleMapController> controllerCompleter =
645+
Completer<GoogleMapController>();
646+
final GoogleMap map = GoogleMap(
647+
initialCameraPosition: _kInitialCameraPosition,
648+
onMapCreated: (GoogleMapController controller) async {
649+
controllerCompleter.complete(controller);
650+
},
651+
);
652+
await pumpWidget(Directionality(
653+
textDirection: TextDirection.ltr,
654+
child: MaterialApp(
655+
home: Scaffold(
656+
body: SizedBox(height: 100, width: 100, child: map)))));
657+
final GoogleMapController controller = await controllerCompleter.future;
658+
659+
await pumpWidget(Directionality(
660+
textDirection: TextDirection.ltr,
661+
child: MaterialApp(
662+
home: Scaffold(
663+
body: SizedBox(height: 400, width: 400, child: map)))));
664+
665+
// We suspected a bug in the iOS Google Maps SDK caused the camera is not properly positioned at
666+
// initialization. https://github.com/flutter/flutter/issues/24806
667+
// This temporary workaround fix is provided while the actual fix in the Google Maps SDK is
668+
// still being investigated.
669+
// TODO(cyanglaz): Remove this temporary fix once the Maps SDK issue is resolved.
670+
// https://github.com/flutter/flutter/issues/27550
671+
await Future<dynamic>.delayed(const Duration(seconds: 3));
672+
673+
// Simple call to make sure that the app hasn't crashed.
674+
final LatLngBounds bounds1 = await controller.getVisibleRegion();
675+
final LatLngBounds bounds2 = await controller.getVisibleRegion();
676+
expect(bounds1, bounds2);
677+
});
641678
}

packages/google_maps_flutter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: google_maps_flutter
22
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
33
author: Flutter Team <[email protected]>
44
homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter
5-
version: 0.5.21+5
5+
version: 0.5.21+6
66

77
dependencies:
88
flutter:

0 commit comments

Comments
 (0)