toTitleCase method

String toTitleCase()

Converts each word in the string to Title Case

Implementation

String toTitleCase() {
  if (isEmpty) return this;
  return split(' ').map((word) {
    if (word.isEmpty) return word;
    return word[0].toUpperCase() + word.substring(1).toLowerCase();
  }).join(' ');
}