Fix: shorten text

This commit is contained in:
2024-06-07 14:57:28 +03:00
parent 0170505376
commit 65c8f56e20
7 changed files with 45 additions and 11 deletions

9
lib/tools/text.dart Normal file
View 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;
}
}