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