File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 1
1
2
+ ## 2.3.0
3
+ - Add more String extensions.
4
+
2
5
## 2.2.0
3
6
- Add ` mapIndexed2 ` - replacement for built-in mapIndexed which uses sync*
4
7
- Add ` where ` extension on Map type - returning new map instance.
Original file line number Diff line number Diff line change @@ -51,6 +51,33 @@ extension StringExtensions on String {
51
51
52
52
return replaceAll (pattern, '' );
53
53
}
54
+
55
+ String capitalize () {
56
+ if (length < 2 ) return this ;
57
+
58
+ return '${this [0 ].toUpperCase ()}${characters .getRange (1 ).toLowerCase ()}' ;
59
+ }
60
+
61
+ String shorten (int maxLength) {
62
+ if (length < maxLength) return this ;
63
+
64
+ return '${characters .getRange (0 , maxLength )}...' ;
65
+ }
66
+
67
+ String stripOuterQuotes () {
68
+ var result = this ;
69
+ if (result.startsWith ('"' )) result = result.replaceFirst ('"' , '' );
70
+
71
+ if (result.endsWith ('"' )) result = result.replaceRange (result.length - 1 , null , '' );
72
+
73
+ return result;
74
+ }
75
+
76
+ String firstLetterUppercase () => '${this [0 ].toUpperCase ()}${characters .getRange (1 )}' ;
77
+
78
+ String stripNewLines ([String placeholder = ' ' ]) {
79
+ return replaceAll (RegExp (r'\s+' ), placeholder);
80
+ }
54
81
}
55
82
56
83
extension NullableStringExtensions on String ? {
Original file line number Diff line number Diff line change 1
1
name : netglade_utils
2
- version : 2.2 .0
2
+ version : 2.3 .0
3
3
description : Dart utils used internally at netglade.
4
4
repository : https://github.com/netglade/flutter_core/tree/main/packages/netglade_utils
5
5
issue_tracker : https://github.com/netglade/flutter_core/issues
You can’t perform that action at this time.
0 commit comments