try this:
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r"[0-9.]")),
TextInputFormatter.withFunction((oldValue, newValue) {
final text = newValue.text;
return text.isEmpty
? newValue
: double.tryParse(text) == null
? oldValue
: newValue;
}),
],
demo:
TextFormField(
keyboardType: TextInputType.numberWithOptions(
decimal: true,
signed: false,
),
onChanged: _yourOnChange,
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r"[0-9.]")),
TextInputFormatter.withFunction((oldValue, newValue) {
final text = newValue.text;
return text.isEmpty
? newValue
: double.tryParse(text) == null
? oldValue
: newValue;
}),
],
)