maxLength static method

String? Function(String?) maxLength(
  1. int max, [
  2. String? message
])

Returns a validator that checks whether a field has a maximum length.

Implementation

static String? Function(String?) maxLength(int max, [String? message]) {
  return (value) {
    if (value != null && value.length > max) {
      return message ?? 'Maximum $max characters allowed';
    }
    return null;
  };
}