Fix: shorten text
This commit is contained in:
9
lib/tools/text.dart
Normal file
9
lib/tools/text.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user