toTitleCase method
Converts the string to Title Case (whitespace-separated words).
Implementation
String toTitleCase() {
if (isEmpty) return this;
return collapseWhitespace()
.split(' ')
.map((word) => word.capitalize())
.join(' ');
}