truncate method
Truncates the string to length and appends suffix if it exceeds the length.
Implementation
String? truncate(int length, {String suffix = '...'}) {
if (this == null) return null;
if (length <= 0) return '';
if (this!.length <= length) return this;
return '${this!.substring(0, length)}$suffix';
}