truncate method
String Truncation: An extension to truncate a string to a specified length and add an ellipsis if it exceeds that length.
Implementation
String truncate(int maxLength) {
if (length <= maxLength) return this;
return '${substring(0, maxLength)}...';
}