truncate static method

String truncate(
  1. String value,
  2. int maxLength
)

Truncates text with an ellipsis if it exceeds maxLength.

Implementation

static String truncate(String value, int maxLength) {
  if (value.length <= maxLength) return value;
  return '${value.substring(0, maxLength)}…';
}