Skip to content

TextField, when center aligned, shows caret in the middle when pasting text #22496

@pablote

Description

@pablote

Steps to Reproduce

I have a TextField like this:

child: TextField(
        onChanged: handleInputChange,
        enabled: !disabled,
        textAlign: TextAlign.center,
        style: TextStyle(color: Colors.black, fontSize: 16.0),
        obscureText: obscureText,
        decoration: new InputDecoration(
          contentPadding: const EdgeInsets.all(7.0),
          hintText: hintText,
          border: new OutlineInputBorder(
              borderRadius: new BorderRadius.all(const Radius.circular(5.0))
          )
        ),
      )

As I type, the caret is correctly shown at the end, but if I paste text from my keyboard, like my email which it remembers, the caret is shown in the middle in a weird position, not really in between characters. BTW, this does not happen when left aligned, in which case the caret is correctly advanced to the end.

caret_middle

Logs

N/A

Flutter doctor

$ flutter doctor -v
[✓] Flutter (Channel beta, v0.8.2, on Mac OS X 10.13.6 17G65, locale en-US)
    • Flutter version 0.8.2 at /Users/pablo/Documents/work/projects/forks/flutter
    • Framework revision 5ab9e70727 (3 weeks ago), 2018-09-07 12:33:05 -0700
    • Engine revision 58a1894a1c
    • Dart version 2.1.0-dev.3.1.flutter-760a9690c2

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.2)
    • Android SDK at /Users/pablo/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.2
    • ANDROID_HOME = /Users/pablo/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.0, Build version 10A255
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 28.0.2
    • Dart plugin version 173.4700
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] Connected devices (1 available)
    • Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: text inputEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions