getNumericFormatters static method

List<TextInputFormatter> getNumericFormatters({
  1. bool allowDecimal = true,
  2. int? maxDecimals,
  3. int? maxLength,
  4. bool useNumericFormatter = false,
  5. ValueChanged? onValueChanged,
})

Creates formatters for numeric input with decimal and negative number support

Implementation

static List<TextInputFormatter> getNumericFormatters({
  bool allowDecimal = true,
  int? maxDecimals,
  int? maxLength,
  bool useNumericFormatter = false,
  ValueChanged<dynamic>? onValueChanged,
}) => <TextInputFormatter>[
  if (maxLength != null) _getMaxLengthFormatter(maxLength),

  FilteringTextInputFormatter.digitsOnly,
  if (useNumericFormatter)
    _createNumberFormatFormatter(
      allowDecimal: allowDecimal,
      maxDecimals: maxDecimals,
      onValueChanged: onValueChanged,
    )
  else
    _createNumericValidator(
      allowDecimal: allowDecimal,
      maxDecimals: maxDecimals,
      onValueChanged: onValueChanged,
    ),
];