cut method
Cut the string
suffix
is the string to be added at the end of the string. You may want
to add '...' at the end of the string.
Text( comment.content.cut(56, suffix: '...') );
Implementation
String cut(int length, {String suffix = ''}) {
String temp = this;
temp = temp.trim();
temp = temp.replaceAll('\n', ' ');
temp = temp.replaceAll('\r', ' ');
temp = temp.replaceAll('\t', ' ');
return temp.length > length ? '${temp.substring(0, length)}$suffix' : temp;
}