flutter-masked-text
flutter-masked-text copied to clipboard
Remove mask when deleting
Just started using this library and so far so good. The only thing I noticed is when typing the mask gets inserted automatically, I would infer that when deleting it would automatically remove the mask as well. Right now when deleting, you have to manually delete the mask one by one.
Hi @ryankauk could you provide a scenario, a code sample and maybe some prints to let me check the problem?
Hi @benhurott.
Just simply use any masks with non-numeric value.
eg) TextField(controller: MaskedTextController(mask: "(0) 000 000 000"))
When you type digits, there are 2 issues including what @ryankauk said.
- With typing the first digit of 0, it displays as '(0', not '(0)'
- After typing some more digits, let's say '(0) 12', you have to manually remove brackets with the backspace button which @ryankauk was saying.
Some not very smart but working solution:
my mask
_maskedController = MaskedTextController(mask: '00/00');
and then
_maskedController.beforeChange = (String previous, String next) {
if (next.length == 3) {
if (next[2] == '/') {
_maskedController.text = _maskedController.text.substring(0, _maskedController.text.length - 1);
}
}
return true;
};