Skip to content

TextEditingController.value.composing is giving wrong results in Web & iOS #174159

@rk54rk

Description

@rk54rk

Steps to reproduce

  1. Create an example app with a TextField.
  2. Log its TextEditingController.value.composing.
  3. Run in MacOS, type "n", "h", then select "你好" with pinyin IME.
  4. Run in Web, type "n", "h", then select "你好" with pinyin IME.

Expected results

After the user selects "你好", The final "composing" TextRange should both be (start: -1, end: -1) in MacOS and Web.

Actual results

In MacOS, the final composing TextRange is logged as (start: -1, end: -1), but in Web, the final composing TextRange is logged as (start: 0, end: 2),

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final _controller = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text('test'),
            TextField(
              controller: _controller,
              onChanged: (_) {
                print(_controller.value.composing);
              },
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration Image Image

Logs

Logs

MacOS

flutter: TextRange(start: 0, end: 1)
flutter: TextRange(start: 0, end: 3)
flutter: TextRange(start: -1, end: -1)

Web

TextRange(start: 0, end: 1)
TextRange(start: 0, end: 3)
TextRange(start: 0, end: 2)

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.35.1, on macOS 14.3.1 23D60 darwin-x64, locale
    en-GB) [669ms]
    • Flutter version 3.35.1 on channel stable at /Applications/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 20f8274939 (6 days ago), 2025-08-14 10:53:09 -0700
    • Engine revision 1e9a811bf8
    • Dart version 3.9.0
    • DevTools version 2.48.0
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
    • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop,
      enable-windows-desktop, enable-android, enable-ios, cli-animations,
      enable-lldb-debugging

[✗] Android toolchain - develop for Android devices [325ms]
    • Android SDK at /Users/herongkai/Library/Android/sdk
    • Emulator version unknown
    ✗ cmdline-tools component is missing.
      Try installing or updating Android Studio.
      Alternatively, download the tools from
      https://developer.android.com/studio#command-line-tools-only and make sure
      to set the ANDROID_HOME environment variable.
      See https://developer.android.com/studio/command-line for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 15.3) [1,756ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15E204a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [22ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed) [21ms]
    • Android Studio not found; download from
      https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/macos-android-setup for detailed
      instructions).

[✓] VS Code (version 1.103.1) [19ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.116.0

[✓] Connected device (2 available) [8.3s]
    • macOS (desktop) • macos  • darwin-x64     • macOS 14.3.1 23D60 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 139.0.7258.128
    ! Error: Browsing on the local area network for Pad Thai. Ensure the device
      is unlocked and attached with a cable or associated with the same local
      area network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code
      -27)
    ! Error: Browsing on the local area network for rp. Ensure the device is
      unlocked and attached with a cable or associated with the same local area
      network as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code
      -27)

[✓] Network resources [962ms]
    • All expected network resources are available.

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: text inputEntering text in a text field or keyboard related problemsc: parityWorks on one platform but not anotherengineflutter/engine repository. See also e: labels.f: material designflutter/packages/flutter/material repository.found in release: 3.35Found to occur in 3.35found in release: 3.36Found to occur in 3.36frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyplatform-webWeb applications specificallyteam-text-inputOwned by Text Input team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions