Flutter TextField inputFormatters not wokring with my custom regex
I want to allow this kind of input to my text field:
123
*123#
*123*4#
so I created and tested RegExr
website this regex:
\**\d+\**\d+\#?
but when i try to type nothing is typed in the text field
code of using:
...
keyboardType = TextInputType.phone;
// to allow digits with asterik and hash
final regex = RegExp(r'\**\d+\**\d+\#?');
inputFormatters = [FilteringTextInputFormatter.allow(regex)];
return TextField(
...
keyboardType: keyboardType,
inputFormatters: inputFormatters,
);
Read more here: Source link