0

What is the idiomatic way to limit input in a Flutter TextField only to these values which match the regexp ^[0-9]+(\.[0-9]+)$?

porton
  • 5,214
  • 11
  • 47
  • 95

1 Answers1

0

Use the property inputFormatters

return TextField(
  inputFormatters: [
    FilteringTextInputFormatter.allow(RegExp(^[0-9]+(\.[0-9]+)$)),
  ],
);

I hope this helps.

Arijeet
  • 935
  • 5
  • 19