toTitleCase method
Converts this string to title case (e.g. 'hello world' -> 'Hello World').
Implementation
String toTitleCase() {
if (isEmpty) return this;
return split(' ')
.map((String word) => word.isEmpty
? word
: '${word[0].toUpperCase()}${word.substring(1).toLowerCase()}')
.join(' ');
}