ucwords property
String
ucwords
print('john doe'.ucwords); // John Doe
Implementation
String get ucwords {
try {
String str = this;
if (str.trim() == '') return '';
List<String> split = str.split(' ');
for (int i = 0; i < split.length; i++) {
if (split[i] != '') {
split[i] = split[i][0].toUpperCase() + split[i].substring(1);
}
}
return split.join(' ');
} catch (e) {
return '';
}
}