Skip to content

TextInputFormatter.formatEditUpdate causes unexpected output with LG Keyboard #78066

Description

@html-rulez-d00d

A hostile bug is occurring with TextFields if you are using an LG Keyboard as the "On-screen keyboard" (which is the default keyboard for LG devices).

Steps to Reproduce

  1. Create a custom TextInputFormatter:
class LowerCaseTextFormatter extends TextInputFormatter {
  @override
  TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
    return TextEditingValue(
      text: newValue.text?.toLowerCase(),
      selection: newValue.selection,
    );
  }
}
  1. Add a widget that takes advantage of the custom formatter:
TextField(
    inputFormatters: [
      LowerCaseTextFormatter()
    ]
)
  1. Type "test" in the TextField.

Expected results: "test" should appear in the TextField

Actual results: "ttesst" appears in the TextField.

Oddly enough, I have had NO issue with the above code for all my other keyboards (iOS, Gboard, Samsung) but one of our users reported the behavior on their LG phone.

Logs
Analyzing flutter_stride...                                             
No issues found! (ran in 20.8s)
[✓] Flutter (Channel unknown, 1.25.0-8.3.pre, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en-US)
    • Flutter version 1.25.0-8.3.pre at /Users/ajachte/projects/software/flutter
    • Framework revision 5d36f2e7f5 (8 weeks ago), 2021-01-14 15:57:49 -0800
    • Engine revision 7a8f8ca02c
    • Dart version 2.12.0 (build 2.12.0-133.7.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/ajachte/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/ajachte/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_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.2, Build version 12B45b
    • CocoaPods version 1.9.3

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

[✓] Android Studio (version 4.1)
    • 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 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.29.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 2.21.1

[✓] Connected device (2 available)
    • LG LS997 (mobile) • LGLS997e1b7388c • android-arm64  • Android 8.0.0 (API 26)
    • Chrome (web)      • chrome          • web-javascript • Google Chrome 89.0.4389.82

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions