Skip to content

Commit dfc4263

Browse files
committed
feat(extensions): add string truncate functionality
- Implement StringTruncate extension to truncate strings to a specified maximum length - Add new exports for source_type_l10n.dart and string_truncate.dart in extensions.dart
1 parent 4da0c34 commit dfc4263

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/shared/extensions/extensions.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export 'content_status_l10n.dart';
2+
export 'source_type_l10n.dart';
3+
export 'string_truncate.dart';
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extension StringTruncate on String {
2+
String truncate(int maxLength) {
3+
if (length <= maxLength) {
4+
return this;
5+
}
6+
return '${substring(0, maxLength)}...';
7+
}
8+
}

0 commit comments

Comments
 (0)