0

Only one or two digits number before the decimal point in texfFormField flutter. And User can't add more than three digits after the decimal point.

2 Answers2

0

If your String what the user typed is called value:

List<String> split = value.split('.');
if (split.elementAt(0).length > 2 || split.elementAt(1).length > 3) print('Not valid'); 

If you need something more advanced: How to allow only 2 digits and 1 digit after the comma (.)?

stacktrace2234
  • 1,172
  • 1
  • 12
  • 22
0

you can use RegExp class

final isValidNumber = RegExp(r'^([0-9]{2})*\.[0-9]{2}$');

if (!isValidNumber .hasMatch(number))
    numbererror = "Please Enter Valid Name";
else
   numbererror = "";