ellipsis method

String? ellipsis({
  1. int maxLength = 20,
  2. String replaceWith = '...',
})

Implementation

String? ellipsis({int maxLength = 20, String replaceWith = '...'}) {
  if (this == null)
    return null;
  else if (this!.length <= maxLength) return this;

  String sub = this!.substring(0, maxLength).trim();
  return '$sub$replaceWith';
}