bhrott / flutter-masked-text

A masked text for Flutter.
https://pub.dartlang.org/packages/flutter_masked_text
MIT License
276 stars 124 forks source link

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

Open marcglasberg opened 5 years ago

marcglasberg commented 5 years ago

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.

bhrott commented 5 years ago

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).

marcglasberg commented 5 years ago

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.

jorgevvr commented 5 years ago

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.

cbfischer commented 5 years ago

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

AlexanderArendar commented 5 years ago

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

PauloKeller commented 5 years ago

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)

Katekko commented 5 years ago

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

bhrott commented 5 years ago

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.

gosoares commented 5 years ago

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)

rockerbacon commented 5 years ago

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

andredealmei commented 5 years ago

Same issue here.

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

flenair commented 5 years ago

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)

DoisLucas commented 5 years ago

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)

petrc commented 5 years ago

Same issue on Android 9 emulator (API 28)

valterh4ck3r commented 5 years ago

FIX

Hello Sirs, i update the flutter to

v1.7.8+hotfix.4

On channel stable.

andre-bahia commented 4 years ago

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

jeaanlucas commented 4 years ago

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

valterh4ck3r commented 4 years ago

@jeaanlucas

Update you flutter.

jeaanlucas commented 4 years ago

@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.
valterh4ck3r commented 4 years ago

@jeaanlucas

Run

flutter clean flutter clear pub cache flutter repo update

After rebuild your app.

louia commented 4 years ago

Any updates on this issue?

kelvinmontini commented 4 years ago

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