Skip to content

Commit c3f21d3

Browse files
committed
Add string lenght check for capitalize
1 parent 7248828 commit c3f21d3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/netglade_utils/lib/src/extensions/string_extensions.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ extension StringExtensions on String {
5353
}
5454

5555
String capitalize() {
56+
if (length < 2) return this;
57+
5658
return '${this[0].toUpperCase()}${characters.getRange(1).toLowerCase()}';
5759
}
5860

0 commit comments

Comments
 (0)