truncateText static method
Truncate a text
to the specified maxLength
and append '...' if it exceeds.
Implementation
static String truncateText(String text, int maxLength) {
if (text.length <= maxLength) {
return text;
} else {
return '${text.substring(0, maxLength)}...';
}
}