truncate method
Returns the string truncated to a specified length, optionally adding ellipsis.
Implementation
String truncate(int maxLength, {String ellipsis = '...'}) {
if (isEmpty) return this;
if (length <= maxLength) return this;
return '${substring(0, maxLength)}$ellipsis';
}