truncate method
Truncate to max chars; append ellipsis if truncated.
Implementation
String truncate(int max, {String ellipsis = '…'}) {
if (length <= max || max <= 0) return this;
if (max <= ellipsis.length) return ellipsis.substring(0, max);
return substring(0, max - ellipsis.length) + ellipsis;
}