trimWithEllipsis method

String trimWithEllipsis({
  1. int minLength = 5,
})

Truncates with ellipsis at both ends.

Implementation

String trimWithEllipsis({int minLength = 5}) {
  if (length < minLength) return ellipsis;
  if (length < (minLength * 2) + 2) {
    return substringSafe(0, minLength) + ellipsis;
  }
  return substringSafe(0, minLength) + ellipsis + substringSafe(length - minLength);
}