capitalize static method
Capitalize each word inside string
字符串内的每个单词都要大写
Example: your name => Your Name, your name => Your name
If First Only is true, the only letter get uppercase is the first letter
Implementation
static String? capitalize(String s, {bool firstOnly = false}) {
if (ObjectUtils.isNullOrBlank(s)) return null;
if (firstOnly) return capitalizeFirst(s);
List lst = s.split(' ');
String newStr = '';
for (var s in lst) {
newStr += capitalizeFirst(s) ?? '';
}
return newStr;
}