Repository: flutter
Issue: Flutter 3.7 breaks TextField widgets that wrap MaterialApp.router
Labels: a: text input,c: regression,framework,f: material design,f: routes,has reproducible steps,found in release: 3.7,found in release: 3.8,team-design,triaged-design

## Steps to Reproduce

<!-- Please include full steps to reproduce so that we can reproduce the problem. -->
After updating to Flutter 3.7, when a TextField gains focus, the keyboard appears but then immediately is dismissed. This issue was originally reported [here](https://github.com/wiredashio/wiredash-sdk/issues/262). I have confirmed that this issue does not occur in Flutter v3.3. This bug only occurs when a Router is used and only seems to occur for TextFields that are outside the `MaterialApp` in the widget tree. It is _not_ specific to the [wiredash](https://pub.dev/packages/wiredash) package. I've tested it with [flappy](https://pub.dev/packages/flappy) and the same thing happens.

1. Download the [Wiredash sample repo](https://github.com/percula/wiredash_test)
2. Run the sample on an iOS or Android device. There is no need to provide the Wiredash `projectId` or `secret`.
3. Tap the FAB to bring up the Wiredash interface
4. Try to type in the `TextField`

**Expected results:** <!-- what did you want to see? -->
The keyboard will appear and remain.

**Actual results:** <!-- what did you see? -->
The keyboard appears and immediately dismisses.

![216086169-621711f4-49f7-4e1e-a127-5a971b4c53a6](https://user-images.githubusercontent.com/16809252/216428514-4a868de7-04fb-4d38-bf0b-5a532cef3ae8.gif)

<details>
<summary>Code sample</summary>

See the [sample project](https://github.com/percula/wiredash_test).

</details>

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue. If there is a crash, please include
      the entirety of the crash log including the backtrace.
-->

```
[+9897 ms] D/InputMethodManager(18732): showSoftInput() view=io.flutter.embedding.android.FlutterView{71fcbaf VFED..... .F....ID 0,0-1080,2337 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
[  +35 ms] W/OnBackInvokedCallback(18732): OnBackInvokedCallback is not enabled for the application.
[        ] W/OnBackInvokedCallback(18732): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
[  +17 ms] D/InsetsController(18732): show(ime(), fromIme=true)
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
+9897 ms] D/InputMethodManager(18732): showSoftInput() view=io.flutter.embedding.android.FlutterView{71fcbaf VFED..... .F....ID 0,0-1080,2337 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
[  +35 ms] W/OnBackInvokedCallback(18732): OnBackInvokedCallback is not enabled for the application.
[        ] W/OnBackInvokedCallback(18732): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
[  +17 ms] D/InsetsController(18732): show(ime(), fromIme=true)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
[!] Flutter (Channel stable, 3.7.1, on macOS 12.6 21G115 darwin-arm64, locale en-US)
    • Flutter version 3.7.1 on channel stable at /Users/peter/development/flutter
    ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.16.1/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/peter/development/flutter. Consider adding
      /Users/peter/development/flutter/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7048ed95a5 (26 hours ago), 2023-02-01 09:07:31 -0800
    • Engine revision 800594f1f4
    • Dart version 2.19.1
    • DevTools version 2.20.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
    • Android SDK at /Users/peter/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0-rc1
    • Java binary at: /opt/homebrew/opt/openjdk@17/bin/java
    • Java version OpenJDK Runtime Environment Homebrew (build 17.0.6+0)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

[✓] Connected device (3 available)
    • Pixel 7 (mobile) • adb-28281FBH2003ZL-0vnWNw._adb-tls-connect._tcp. • android-arm64  • Android 13 (API 33)
    • macOS (desktop)  • macos                                            • darwin-arm64   • macOS 12.6 21G115 darwin-arm64
    • Chrome (web)     • chrome                                           • web-javascript • Google Chrome 109.0.5414.119

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 2 categories.

```

</details>


<!--
      Consider also attaching screenshots and/or videos to better
      illustrate the issue.

      You can upload them directly on GitHub.
      Beware that video file size is limited to 10MB.
-->