toUpperAllFirstLetter method
Implementation
String toUpperAllFirstLetter(String text) {
if (text.length <= 1) {
return text.toUpperCase();
}
text = text.toLowerCase();
final words = text.split(' ');
final capitalized = words.map((word) {
final first = word.substring(0, 1).toUpperCase();
final rest = word.substring(1);
return '$first$rest';
});
return capitalized.join(' ');
}