10 lines
258 B
Dart
10 lines
258 B
Dart
String shortString(String text, {int length = 10}) {
|
|
if (text.length > length) {
|
|
String shortText = text.substring(0, length);
|
|
return shortText +
|
|
(text.substring(0, length + 1).endsWith(' ') ? '' : '...');
|
|
} else {
|
|
return text;
|
|
}
|
|
}
|