InputFormatter should allow negative and decimal numbers

804 views Asked by At

I want to allow users to just adding numbers like 123456.78912445, -12345.7777777899, 1234567, -12345678. There is no number limit. How can i write Regrex pattern for this textformfield. Same Question inputFormatter should allow just decimal numbers and negative numbers

TextFormField(inputFormatters:[FilteringTextInputFormatter.allow(RegExp())])
1

There are 1 answers

0
Thai Do On BEST ANSWER

Try this: ^\-*\d+(?:.\d+)?$

And example: https://regex101.com/r/yQDyoM/1