truncate method
Shortens the string to a specified length with an optional ellipsis.
Implementation
String truncate(int maxLength, {String ellipsis = '...'}) {
if (maxLength <= 0) return ellipsis;
if (length <= maxLength) return this;
return '${substring(0, maxLength)}$ellipsis';
}