InputFormatter 应该允许负数和小数

InputFormatter should allow negative and decimal numbers

我想让用户只添加数字,例如 123456.78912445, -12345.7777777899, 1234567, -12345678。 没有数量限制。 我如何为这个 textformfield 编写正则表达式模式。 同样的问题

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

试试这个:^\-*\d+(?:.\d+)?$

以及示例:https://regex101.com/r/yQDyoM/1