File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
packages/netglade_utils/lib/src/extensions Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,31 @@ extension StringExtensions on String {
51
51
52
52
return replaceAll (pattern, '' );
53
53
}
54
+
55
+ String capitalize () {
56
+ return '${this [0 ].toUpperCase ()}${characters .getRange (1 ).toLowerCase ()}' ;
57
+ }
58
+
59
+ String shorten (int maxLength) {
60
+ if (length < maxLength) return this ;
61
+
62
+ return '${characters .getRange (0 , maxLength )}...' ;
63
+ }
64
+
65
+ String stripOuterQuotes () {
66
+ var result = this ;
67
+ if (result.startsWith ('"' )) result = result.replaceFirst ('"' , '' );
68
+
69
+ if (result.endsWith ('"' )) result = result.replaceRange (result.length - 1 , null , '' );
70
+
71
+ return result;
72
+ }
73
+
74
+ String firstLetterUppercase () => '${this [0 ].toUpperCase ()}${characters .getRange (1 )}' ;
75
+
76
+ String stripNewLines ([String placeholder = ' ' ]) {
77
+ return replaceAll (RegExp (r'\s+' ), placeholder);
78
+ }
54
79
}
55
80
56
81
extension NullableStringExtensions on String ? {
You can’t perform that action at this time.
0 commit comments