Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with MoneyMaskedTextController cursor #53

Open
erpriliano opened this issue Mar 4, 2020 · 12 comments
Open

Problem with MoneyMaskedTextController cursor #53

erpriliano opened this issue Mar 4, 2020 · 12 comments

Comments

@erpriliano
Copy link

Hi, I've got a problem below :

ezgif com-resize (1)

The cursor always seem to move to the start of the textfield. Is there any solution to this? Cause this happens to give user a bad experience when filling in the form.

My code that related to this :

final _priceController = MoneyMaskedTextController(
    precision: 0, 
    decimalSeparator: '', 
    thousandSeparator: ',',
  );

Awaiting your response, sir

@rafaelmpessoa
Copy link

same here, anyone resolve ?

@phungnc
Copy link

phungnc commented Apr 6, 2020

Try this

 controller.afterChange = (_, __) {
      controller.selection = TextSelection.collapsed(
        offset: controller.text.length,
      );
    };

@alanbre
Copy link

alanbre commented Apr 14, 2020

Same problem here using the MaskedTextController...

@azamatdev
Copy link

The same problem. @phungnc could you clarify how to use your code. I tried to add it but could not make it

@erpriliano
Copy link
Author

@benhurott we need your help, sir

@phungnc
Copy link

phungnc commented May 8, 2020

@azamatdev

  1. create a MoneyMaskedTextController:
final myController = new MoneyMaskedTextController();
  1. inside your initState, set the afterChange hook like this
  @override
  void initState() {
    super.initState();
    myController.afterChange = (_, __) {
      myController.selection = TextSelection.collapsed(
        offset: myController.text.length,
      );
    };
  }
  1. listening for changes to the text form field
 TextFormField(
     controller: myController,
...

@hikmawanaz
Copy link

@azamatdev

  1. create a MoneyMaskedTextController:
final myController = new MoneyMaskedTextController();
  1. inside your initState, set the afterChange hook like this
  @override
  void initState() {
    super.initState();
    myController.afterChange = (_, __) {
      myController.selection = TextSelection.collapsed(
        offset: myController.text.length,
      );
    };
  }
  1. listening for changes to the text form field
 TextFormField(
     controller: myController,
...

I have tried this solution, it's work but not perfectly. In iOS devices, this solution make backspace(delete) not working.

@hikmawanaz
Copy link

Any solution for this issue?

@rumarka
Copy link

rumarka commented Dec 24, 2020

@azamatdev

  1. create a MoneyMaskedTextController:
final myController = new MoneyMaskedTextController();
  1. inside your initState, set the afterChange hook like this
  @override
  void initState() {
    super.initState();
    myController.afterChange = (_, __) {
      myController.selection = TextSelection.collapsed(
        offset: myController.text.length,
      );
    };
  }
  1. listening for changes to the text form field
 TextFormField(
     controller: myController,
...

I have tried this solution, it's work but not perfectly. In iOS devices, this solution make backspace(delete) not working.

myController.afterChange = (previous, next) {
  if (previous.length < next.length) {
    myController.moveCursorToEnd();
  }
};

@leszekkrol
Copy link

Anu update? I have the same issue

@romreed
Copy link

romreed commented Feb 17, 2021

2021 year but this bug still work. any updates?

@hikmawanaz
Copy link

use another library is only the one solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants