decimalValueFormatter static method

dynamic decimalValueFormatter({
  1. int decimalPlaceValue = 2,
  2. bool allowedSign = false,
})

validation input decimal value

Implementation

static decimalValueFormatter({
  int decimalPlaceValue = 2,
  bool allowedSign = false,
}) {
  return allowedSign
      ? FilteringTextInputFormatter.allow(
        RegExp(
          r'^\d+\.?\d{0,'
          "${decimalPlaceValue.toString()}"
          '}',
        ),
      )
      : FilteringTextInputFormatter.allow(
        RegExp(
          r'^\d+\.?\d{0,'
          "${decimalPlaceValue.toString()}"
          '}',
        ),
      );
}