isTooLong method

String? isTooLong({
  1. int? maxLength = 25,
  2. String? valueName,
})

isTooShort compares the length of a string to the maxLength to ensure it is less than the maxLength. Provides a basic error message that can be used. 'valueName must be less than (maxLength + 1) characters.' A return value of null indicates a valid length.

thows an ArgumentError if valueName is null or the String value is null.

Implementation

String? isTooLong({
  int? maxLength = 25,
  String? valueName,
}) {
  if (this == null) {
    throw ArgumentError('value is required', this);
  }
  if (valueName == null) {
    throw ArgumentError('value name is required', valueName);
  }
  return this!.length > maxLength!
      ? '$valueName must be less than ${maxLength + 1} characters.'
      : null;
}