max method
FormFieldValidator
that requires the field's value to be less than
or equal to the provided number.
Implementation
static FormFieldValidator max(
num max, {
String errorText,
}) {
return (val) {
if (val != null) {
if ((val is num && val > max) ||
(val is String &&
num.tryParse(val) != null &&
num.tryParse(val) > max)) {
return errorText ?? "Value must be less than or equal to $max";
}
}
};
}