Skip to content

Text fields' values do not get trimmed correctly when textDirection: TextDirection.rtl #68093

@HasanAlyazidi

Description

@HasanAlyazidi

Steps to Reproduce

  1. Run flutter create bug.
  2. Create a simple widget
  3. Add a TextFormField or TextField widget with textDirection: TextDirection.rtl
  4. Print trimmed value inside onChanged

Expected results:
I expect when i call trim() on the value of the text field returned from onChanged or controller.text, it should get trimmed.

when i type " str ", "str ", " str" it should remove the leading and trailing whitespaces and return: 'str'

Actual results:
It does not get trimmed correctly if textDirection: TextDirection.rtl, but, it works just fine if textDirection: TextDirection.ltr.

Here is a working demo of the bug:
https://dartpad.dev/b6130da3c610e01d4cc2ddf0ab278d3e

Logs

No exceptions

Analyzing bug...
No issues found! (ran in 3.4s)

[✓] Flutter (Channel stable, 1.20.4, on Microsoft Windows [Version 10.0.19041.508], locale en-US)
• Flutter version 1.20.4 at X:\Development\Configurations\flutter
• Framework revision fba99f6 (4 weeks ago), 2020-09-14 15:32:52 -0700
• Engine revision d1bc06f032
• Dart version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at X:\Development\Configurations\android\sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = X:\Development\Configurations\android\sdk
• ANDROID_SDK_ROOT = X:\Development\Configurations\android\sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.

[✓] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 48.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[✓] VS Code (version 1.50.0)
• VS Code at C:\Users\USR\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.15.0

[✓] Connected device (1 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: internationalizationSupporting other languages or locales. (aka i18n)a: text inputEntering text in a text field or keyboard related problemsa: typographyText rendering, possibly libtxtf: material designflutter/packages/flutter/material repository.found in release: 1.22Found to occur in 1.22frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions