numeric static method

FormFieldValidator numeric({
  1. String errorText = "Value must be numeric.",
})

FormFieldValidator that requires the field's value to be a valid number.

Implementation

static FormFieldValidator numeric({
  String errorText = "Value must be numeric.",
}) {
  return (valueCandidate) {
    var valueString = "$valueCandidate";
    if (num.tryParse(valueString) == null && valueString.isNotEmpty) {
      return errorText;
    }
    return null;
  };
}