maxLength method

String? maxLength(
  1. int length
)

Implementation

String? maxLength(int length) {
  if (this == null) return null;
  if (this!.isEmpty) return this;
  if (length <= 0) return this;
  if (length > this!.length) return this;
  return this!.substring(0, length);
}