maxLength static method

String? maxLength(
  1. String? value,
  2. int max, [
  3. String? fieldName
])

Implementation

static String? maxLength(String? value, int max, [String? fieldName]) {
  final name = fieldName ?? 'This field';
  if (value != null && value.trim().length > max) {
    return '$name must be at most $max characters.';
  }
  return null;
}