Repository: flutter
Issue: Webview does not take the keyboard focus
Labels: p: webview,package,p: webview-keyboard,team-ecosystem,has reproducible steps,P2,workaround available,triaged-ecosystem,found in release: 3.19,found in release: 3.22

### Steps to reproduce

1. Create a flutter app with a `Scaffold`, `AppBar`, `Drawer` and/or AppBar actions and of cause a `WebView` as body
2. Click on an input field or textarea within the webview
3. Open the drawer with a bluetooth keyboard and close it
4. Try to type "Hello World" with a connected bluetooth keyboard

### Expected results

The text field should have the value "Hello World"

### Actual results

The text field has the value "Hello" and a more or less random AppBar interaction was executed like the drawer has opened or the app bar action was executed.

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const WebViewPage(),
    );
  }
}

class WebViewPage extends StatefulWidget {
  const WebViewPage({super.key});

  @override
  State<WebViewPage> createState() => _WebViewPageState();
}

class _WebViewPageState extends State<WebViewPage> {
  late final webViewController = WebViewController()
    ..setJavaScriptMode(JavaScriptMode.unrestricted)
    ..loadRequest(Uri.parse('https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea'));

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // TRY THIS: Try changing the color here to a specific color (to
        // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
        // change color while the other colors stay the same.
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text('Demo'),
        actions: [
          IconButton(onPressed: () {
            ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Yep you used the action')));
          }, icon: const Icon(Icons.developer_mode))
        ],
      ),
      drawer: const Drawer(
        child: Text('Demo Drawer'),
      ),
      body: WebViewWidget(controller: webViewController),
    );
  }
}
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

https://github.com/flutter/flutter/assets/4619618/51e98f63-2a14-490f-9119-372e8d3d1611

</details>


### Logs

<details open><summary>Logs</summary>

```console
I see nothing helpful here
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.6, on macOS 14.4.1 23E224 darwin-arm64, locale de-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] Connected device (3 available)            
[✓] Network resources

• No issues found!
```
Same behavior on Windows
</details>