extCapitalizeWord method
Implementation
String extCapitalizeWord() {
if (isEmpty) return '';
//* Each sentence becomes an array element
List<String> words = split(' ');
if (words.isEmpty) return this;
//* Initialize string as empty string
String output = '';
//* Loop through each sentence
for (var word in words) {
String capitalized = '';
if (word.isEmpty) {
capitalized = '';
} else if (word.length > 1) {
capitalized = word[0].toUpperCase() + word.substring(1);
} else {
capitalized = word[0].toUpperCase();
}
//* Add current sentence to output with a period
output += "$capitalized ";
}
return output;
}