Repository: flutter
Issue: Input methods get interrupted when TextField constraints change
Labels: a: text input,engine,platform-web,a: desktop,has reproducible steps,P2,found in release: 3.7,found in release: 3.8,team-engine,triaged-engine

This was originally reported in #120557 but I was told to file this as a separate issue.

## Steps to Reproduce

<!-- Please include full steps to reproduce so that we can reproduce the problem. -->

1. Execute `flutter run` on the code sample. Choose **Web** as the platform. <!-- (see "Code sample" section below) -->
2. Switch to Chinese input method. Other input methods may also have this issue but I haven't tested them. <!-- describe steps to demonstrate bug -->
3. Try to compose Chinese characters. You'll see that it is impossible to compose any Chinese character in this TextField. <!-- for example "Tap on X and see a crash" -->

This issue also depends on the input method and the platform. It can be reproduced with the default Chinese Pinyin IME on both Chrome and Safari on macOS (user reports Windows is affected too), but not on iOS.

**Expected results:** <!-- what did you want to see? --> Expected to be able to compose Chinese characters normally, as in a native text field.

**Actual results:** <!-- what did you see? -->
Input method keeps getting interrupted, making it impossible to compose any Chinese character.

<details>
<summary>Code sample</summary>

<!--
      Please create a minimal reproducible sample that shows the problem
      and attach it below between the lines with the backticks.

      To create it you can use `flutter create bug` command and update the `main.dart` file.

      Alternatively, you can use https://dartpad.dev/
      which is capable of creating and running small Flutter apps.

      Without this we will unlikely be able to progress on the issue, and because of that
      we regretfully will have to close it.
-->

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatefulWidget {
  const MainApp({super.key});

  @override
  State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
  final _controller = TextEditingController();

  bool show = false;

  @override
  void initState() {
    super.initState();
    _controller.addListener(() {
      setState(() {
        show = !show;
      });
    });
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Row(
          children: [
            Expanded(
              child: TextField(
                maxLines: null,
                controller: _controller,
                keyboardType: TextInputType.multiline,
              ),
            ),
            Visibility(
              visible: show,
              child: const IconButton(
                  icon: Icon(Icons.zoom_out_sharp), onPressed: null),
            ),
          ],
        ),
      ),
    );
  }
}
```

</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.
-->

```
No logs
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
Analyzing flutter_demo...                                               
No issues found! (ran in 1.6s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 3.7.1, on macOS 13.2 22D49 darwin-x64, locale en-US)
    • Flutter version 3.7.1 on channel stable at /Users/singularity/Projects/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7048ed95a5 (6 days ago), 2023-02-01 09:07:31 -0800
    • Engine revision 800594f1f4
    • Dart version 2.19.1
    • DevTools version 2.20.1

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] 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 (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] VS Code (version 1.75.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.58.0

[!] Proxy Configuration
    • HTTP_PROXY is set
    ! NO_PROXY is not set

[✓] Connected device (3 available)
    • iPhone 14 Pro Max (mobile) • 9AADEBDE-B971-4B5B-9E37-A743968DAD5A • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
    • macOS (desktop)            • macos                                • darwin-x64     • macOS 13.2 22D49 darwin-x64
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 109.0.5414.119

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 3 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.
-->