truncateContent function
- String content
Truncate content to fixed width.
Implementation
String truncateContent(String content) {
int maxLength = 45;
String subStr =
content.length > maxLength ? content.substring(0, maxLength) : content;
int lastCommaIndex = subStr.lastIndexOf(',') + 1;
return '${lastCommaIndex > 0 ? content.substring(0, lastCommaIndex) : subStr} ...';
}