File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ extension StringExtensions on String {
73
73
return result;
74
74
}
75
75
76
- String firstLetterUppercase () => '${this [0 ].toUpperCase ()}${characters .getRange (1 )}' ;
76
+ String firstLetterUppercase () => isNotEmpty ? '${this [0 ].toUpperCase ()}${characters .getRange (1 )}' : ' ' ;
77
77
78
78
String stripNewLines ([String placeholder = ' ' ]) {
79
79
return replaceAll (RegExp (r'\s+' ), placeholder);
Original file line number Diff line number Diff line change @@ -280,5 +280,27 @@ void main() {
280
280
expect (value.ifBlank ('aaa' ), equals (value));
281
281
});
282
282
});
283
+
284
+ group ("firstLetterUppercase" , () {
285
+ test ("empty message" , () {
286
+ final String value = "" ;
287
+ expect (value.firstLetterUppercase (), equals ("" ));
288
+ });
289
+
290
+ test ("message with whitespaces" , () {
291
+ final String value = " " ;
292
+ expect (value.firstLetterUppercase (), equals (value));
293
+ });
294
+
295
+ test ("message with non-whitespace characters" , () {
296
+ final String value = "xxx" ;
297
+ expect (value.firstLetterUppercase (), equals ("Xxx" ));
298
+ });
299
+
300
+ test ("message with 1 character" , () {
301
+ final String value = "x" ;
302
+ expect (value.firstLetterUppercase (), equals ("X" ));
303
+ });
304
+ });
283
305
});
284
306
}
You can’t perform that action at this time.
0 commit comments