max function

String max (
  1. num fieldValue,
  2. int maxVal,
  3. {String message}
)

Validates that fieldValue (int or double) is equal to or smaller than maxVal.

Returns null if fieldValue <= maxVal else an error message

Implementation

String max(
  num fieldValue,
  int maxVal, {
  String message,
}) {
  if ((fieldValue == null) || (fieldValue <= maxVal)) {
    return null;
  }
  return message ?? 'Please enter a value smaller or equal to $maxVal';
}