You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was going through a problem when editing a value in a masked input. For example, if the user typed his phone "(54) 99999-9999" and wanted to change it to "(54) 94999-9999" the input would put the number 4 in the end of the text, like "(54) 99999-9994".
So, following the initial suggestion made by Marc in the #16 , i change the text method to this:
@overridesettext(String newText) {
print(newText);
if (super.text != newText) {
int position =this.selection.baseOffset >=super.text.length
? (newText ??'').length
:this.selection.baseOffset;
value = value.copyWith(
text: newText,
selection:TextSelection.collapsed(offset: position),
composing:TextRange.empty);
}
}
Basically, I only put the cursor at the end of the text, if it was already at the end.
Hope it helps (:
The text was updated successfully, but these errors were encountered:
thanks but this is not working correctly either. Imagine value 15,000,000.
changing it into 12,000,000 or 10,000,000 works perfectly fine. but when you try to change it into 15,500,000 you endup with value 15,000,005 :D anyway thank you.
I was going through a problem when editing a value in a masked input. For example, if the user typed his phone "(54) 99999-9999" and wanted to change it to "(54) 94999-9999" the input would put the number 4 in the end of the text, like "(54) 99999-9994".
So, following the initial suggestion made by Marc in the #16 , i change the text method to this:
Basically, I only put the cursor at the end of the text, if it was already at the end.
Hope it helps (:
The text was updated successfully, but these errors were encountered: