Problem with MoneyMaskedTextController cursor
erpriliano opened this issue · comments
Hi, I've got a problem below :
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
same here, anyone resolve ?
Try this
controller.afterChange = (_, __) {
controller.selection = TextSelection.collapsed(
offset: controller.text.length,
);
};
Same problem here using the MaskedTextController...
The same problem. @phungnc could you clarify how to use your code. I tried to add it but could not make it
@benhurott we need your help, sir
- create a MoneyMaskedTextController:
final myController = new MoneyMaskedTextController();
- inside your
initState
, set theafterChange
hook like this
@override
void initState() {
super.initState();
myController.afterChange = (_, __) {
myController.selection = TextSelection.collapsed(
offset: myController.text.length,
);
};
}
- listening for changes to the text form field
TextFormField(
controller: myController,
...
- create a MoneyMaskedTextController:
final myController = new MoneyMaskedTextController();
- inside your
initState
, set theafterChange
hook like this@override void initState() { super.initState(); myController.afterChange = (_, __) { myController.selection = TextSelection.collapsed( offset: myController.text.length, ); }; }
- 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.
Any solution for this issue?
- create a MoneyMaskedTextController:
final myController = new MoneyMaskedTextController();
- inside your
initState
, set theafterChange
hook like this@override void initState() { super.initState(); myController.afterChange = (_, __) { myController.selection = TextSelection.collapsed( offset: myController.text.length, ); }; }
- 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();
}
};
Anu update? I have the same issue
2021 year but this bug still work. any updates?
use another library is only the one solution