Repository: flutter
Issue: [Android] CJK IME candidate window position error with external keyboard on Android
Labels: a: text input,platform-android,a: internationalization,P2,team-text-input,triaged-text-input

### Steps to reproduce

1. Connect a physical keyboard (e.g., a Bluetooth keyboard) to your Android device.
2. Switch to a CJK input method (e.g., Chinese) and start typing to trigger candidate words.

### Expected results

The candidate window should be displayed correctly near the cursor to ensure a seamless user experience. With the increasing popularity of Android tablets, many of which are commonly used with physical keyboards, it has become essential to address this issue. Correctly positioning the candidate window is critical for maintaining usability and consistency across devices, especially for users relying on CJK input methods. Fixing this bug will significantly improve the input experience for a growing segment of Android users.

### Actual results

On Android devices, the candidate window for the input method is incorrectly displayed in the lower-left corner of the screen. In contrast, on iOS and desktop devices, the candidate window appears in the correct position. I used Gboard as the input method on Android and tested other input methods as well, but the issue persisted. This suggests that the problem is not related to a specific input method.

### Code sample

<details open><summary>Code sample</summary>
This is a very simple example that contains only a textfiled.

```dart
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(
      home: Scaffold(
        body: Center(
          child: TextField(),
        ),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

## Android (incorrect position)

https://github.com/user-attachments/assets/a8cd4819-7af1-4910-8d80-4a6400d13d1f

## ios (correct position)

https://github.com/user-attachments/assets/0876ab3b-bfae-4fbb-ab30-4630f2093074


</details>


### Logs

_No response_

### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[✓] Flutter (Channel beta, 3.27.0-0.2.pre, on macOS 15.1.1 24B91 darwin-arm64,
    locale zh-Hans-CN)
    • Flutter version 3.27.0-0.2.pre on channel beta at
      /Users/alex/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision fc011960a2 (2 weeks ago), 2024-11-14 12:19:18 -0800
    • Engine revision 397deba30f
    • Dart version 3.6.0 (build 3.6.0-334.4.beta)
    • DevTools version 2.40.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/alex/development/Android
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✗] Chrome - develop for the web (Cannot find Chrome executable at
    /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Android Studio (version 2024.2)
    • 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
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.3)
    • IntelliJ at /Applications/IntelliJ IDEA Ultimate.app
    • 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

[✓] VS Code (version 1.95.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • 晦气4 (mobile)                    • 00008103-000A488102D9001E • ios
      • iOS 18.2 22C5142a
    • macOS (desktop)                 • macos                     • darwin-arm64
      • macOS 15.1.1 24B91 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin
      • macOS 15.1.1 24B91 darwin-arm64
    ! Error: Browsing on the local area network for iPhone SE. 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
    ✗ A cryptographic error occurred while checking "https://cocoapods.org/":
      Connection terminated during handshake
      You may be experiencing a man-in-the-middle attack, your network may be
      compromised, or you may have malware installed on your computer.

! Doctor found issues in 2 categories.

```

</details>