flutter-masked-text icon indicating copy to clipboard operation
flutter-masked-text copied to clipboard

O cursor vai pra posição 0 assim que uma tecla é digitada.

Open marcglasberg opened this issue 5 years ago • 22 comments

No setter do text, faça isso:

  @override
  set text(String newText) {
  if (super.text != newText) {
  value = value.copyWith(
      text: newText,
      selection: TextSelection.collapsed(offset: (newText ?? '').length),
      composing: TextRange.empty);
    }
  }

Isso resolverá um bug que ocorre quando as vezes o cursor vai pra posição 0 assim que uma tecla é digitada.

O mesmo fix pode ser aplicado no updateValue.

marcglasberg avatar Nov 11 '18 15:11 marcglasberg

Hi,

Can you add the information about SO (Android or iOS) and Flutter Version? If possible, can you send a code sample?

Because I can't reproduce this (I tested in iOS and Android simulator).

bhrott avatar Nov 12 '18 03:11 bhrott

Flutter v0.9.4. It works in my simulator too. You can reproduce it only in the real phone (Galaxy S7 in my case). I have no idea why.

marcglasberg avatar Nov 12 '18 14:11 marcglasberg

This happens to me too, when the mask character is inserted the cursor back to the initial position, example: 123- when the "-" is inserted the cursor backs to the initial position, the "-" is defined in the mask. Hope you can find a fix for that.

jorgevvr avatar Mar 15 '19 11:03 jorgevvr

I have the same problem. This issue can be reproduce in a real device.

cbfischer avatar Apr 01 '19 23:04 cbfischer

Hi benhurott,

I used the MaskedTextController in my custom form field and noticed the same issue. Each time when the mask character is encountered the visible cursor position resets. Then user continues typing then it appends the characters at a proper positions though. For example, consider my case where the format is a US phone number (000) 000-0000. In this case the first symbol is a mask character so when the user starts typing the phone number the first thins he notices visually is how the cursor position jumps. This needs to be addressed in order for regular users to have normal experience. For me as a developer it is not critical since I understand that I can continue typing and everything will be normal, or I know that I can fix the cursor position by tapping if needed. But average user may find it disturbing.

One more thing I noticed is that when deleting characters and it comes to the mask character the cursor position also jumps to the start.

I use Huawei P10 Pro with Android 8.0.0. Also I use current stable Flutter channel with Flutter version 1.2.1

AlexanderArendar avatar Apr 04 '19 15:04 AlexanderArendar

1+ More Iphone 8 iOS 12 The same issue, cursor back's to start position when start to typing.

flutter_masked_text: 0.8.0 [✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.3 18D109, locale pt-BR) [!] Android toolchain - develop for Android devices (Android SDK 28.0.3) ✗ Android license status unknown. [✓] iOS toolchain - develop for iOS devices (Xcode 10.2) [✓] Android Studio (version 3.3) [✓] VS Code (version 1.32.3) [✓] Connected device (1 available)

PauloKeller avatar Apr 04 '19 16:04 PauloKeller

@AlexanderArendar Exactly!!! Hope that can be fixed soon

Katekko avatar Apr 16 '19 17:04 Katekko

Guys I will try to fix this issue as soon as possible, but I need to test in some other devices. For now, all the simulators work fine and I have only one android device that I can't reproduce.

bhrott avatar Apr 16 '19 19:04 bhrott

I have the same issue.

Device: Galaxy S9+ flutter_masked_text: 0.8.0

[✓] Flutter (Channel stable, v1.2.1, on Linux, locale en_US.UTF-8) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Android Studio (version 3.3) [✓] IntelliJ IDEA Ultimate Edition (version 2019.1) [✓] Connected device (1 available)

gosoares avatar Apr 16 '19 19:04 gosoares

For me the problem is present when the TextFormField is build inside a StatelessWidget but not present when it's build inside a State

rockerbacon avatar Jul 18 '19 17:07 rockerbacon

Same issue here.

On emulador or real xiaomi mi 8 , moto c plus and Galaxy j1

andredealmei avatar Jul 31 '19 01:07 andredealmei

Same issue on Galaxy A5 version flutter_masked_text: 0.8.0

[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale fr-FR) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 10.3) [✓] iOS tools - develop for iOS devices [✓] Android Studio (version 3.3) [✓] IntelliJ IDEA Ultimate Edition (version 2019.2) [✓] Connected device (3 available)

flenair avatar Aug 07 '19 09:08 flenair

I have the same issue.

Device: Galaxy S6 flutter_masked_text: 0.8.0

[√] Flutter (Channel stable, v1.7.8+hotfix.3, on Microsoft Windows [versão 10.0.17134.829], locale pt-BR) [√] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [√] Android Studio (version 3.1) [√] VS Code (version 1.35.1) [√] Proxy Configuration [√] Connected device (1 available)

DoisLucas avatar Aug 12 '19 14:08 DoisLucas

Same issue on Android 9 emulator (API 28)

petrc avatar Aug 27 '19 10:08 petrc

FIX

Hello Sirs, i update the flutter to

v1.7.8+hotfix.4

On channel stable.

valterh4ck3r avatar Sep 02 '19 23:09 valterh4ck3r

I was going through this same problem and solved it easily using InputFormatter https://gist.github.com/andre-bahia/14fdb0c751822f848a364b3129df1fed

dependecy used: intl: ^0.15.8

andre-bahia avatar Dec 01 '19 03:12 andre-bahia

Any news? Samsung Tab A 10 have the problem too.

jeaanlucas avatar Feb 04 '20 16:02 jeaanlucas

@jeaanlucas

Update you flutter.

valterh4ck3r avatar Feb 05 '20 19:02 valterh4ck3r

@valterh4ck3r this is my flutter doctor -v:

[✓] Flutter (Channel v1.12.13-hotfixes, v1.12.13+hotfix.7, on Linux, locale pt_BR.UTF-8)
    • Flutter version 1.12.13+hotfix.7 at /home/elotech/Documentos/flutter
    • Framework revision 9f5ff2306b (10 days ago), 2020-01-26 22:38:26 -0800
    • Engine revision a67792536c
    • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /home/elotech/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /home/elotech/Android/Sdk
    • Java binary at: /snap/android-studio/82/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Android Studio (version 3.5)
    • Android Studio at /snap/android-studio/82/android-studio
    • Flutter plugin version 43.0.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[!] IntelliJ IDEA Community Edition (version 2019.3)
    • IntelliJ at /snap/intellij-idea-community/202
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
    • For information about installing plugins, see
      https://flutter.dev/intellij-setup/#installing-the-plugins

[!] VS Code (version 1.41.1)
    • VS Code at /usr/share/code
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • Android SDK built for x86 • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
    • Chrome                    • chrome        • web-javascript • Google Chrome 80.0.3987.87
    • Web Server                • web-server    • web-javascript • Flutter Tools

! Doctor found issues in 2 categories.

jeaanlucas avatar Feb 06 '20 11:02 jeaanlucas

@jeaanlucas

Run

flutter clean flutter clear pub cache flutter repo update

After rebuild your app.

valterh4ck3r avatar Feb 06 '20 16:02 valterh4ck3r

Any updates on this issue?

louia avatar Feb 17 '20 14:02 louia

News!? Same issue on Pixel 2 emulator (API 29)

kelvinmontini avatar Mar 18 '20 19:03 kelvinmontini