truncate method
Truncates the string safely.
Example:
"Hello World".truncate(5); // "Hello..."
Implementation
String truncate(int maxLength, {String suffix = '...'}) {
if (this == null) return '';
if (this!.length <= maxLength) return this!;
return this!.substring(0, maxLength) + suffix;
}