diff --git a/dev/integration_tests/abstract_method_smoke_test/android/app/src/main/kotlin/com/example/abstract_method_smoke_test/MainActivity.kt b/dev/integration_tests/abstract_method_smoke_test/android/app/src/main/kotlin/com/example/abstract_method_smoke_test/MainActivity.kt index 4b7eeb7b1f..acb8afcc6d 100644 --- a/dev/integration_tests/abstract_method_smoke_test/android/app/src/main/kotlin/com/example/abstract_method_smoke_test/MainActivity.kt +++ b/dev/integration_tests/abstract_method_smoke_test/android/app/src/main/kotlin/com/example/abstract_method_smoke_test/MainActivity.kt @@ -4,6 +4,8 @@ import android.content.Context import android.os.Bundle import android.view.inputmethod.InputMethodManager import io.flutter.app.FlutterActivity +import io.flutter.plugin.common.MethodChannel; +import io.flutter.plugin.common.MethodChannel.MethodCallHandler; import io.flutter.plugins.GeneratedPluginRegistrant class MainActivity: FlutterActivity() { @@ -12,8 +14,22 @@ class MainActivity: FlutterActivity() { GeneratedPluginRegistrant.registerWith(this) // Triggers the Android keyboard, which causes the resize of the Flutter view. - // https://github.com/flutter/flutter/issues/40126 + // We need to wait for the app to complete. + MethodChannel(getFlutterView(), "com.example.abstract_method_smoke_test") + .setMethodCallHandler({ call, result -> + toggleInput() + result.success(null) + }) + } + + override fun onPause() { + // Hide the input when the app is closed. + toggleInput() + super.onPause() + } + + fun toggleInput() { val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0) + imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0) } } diff --git a/dev/integration_tests/abstract_method_smoke_test/lib/main.dart b/dev/integration_tests/abstract_method_smoke_test/lib/main.dart index 97638939dc..26ad2158b6 100644 --- a/dev/integration_tests/abstract_method_smoke_test/lib/main.dart +++ b/dev/integration_tests/abstract_method_smoke_test/lib/main.dart @@ -1,7 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; -void main() { +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + const MethodChannel channel = MethodChannel('com.example.abstract_method_smoke_test'); + await channel.invokeMethod('show_keyboard'); runApp(MyApp()); print('Test suceeded'); } @@ -48,9 +52,8 @@ class SecondPage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( body: Column( - children: [ - TextFormField(), - const Expanded( + children: const [ + Expanded( child: GoogleMap( initialCameraPosition: CameraPosition( target: LatLng(0, 0)