toTitleCase method

String toTitleCase()

Converts the string to Title Case (whitespace-separated words).

Implementation

String toTitleCase() {
  if (isEmpty) return this;
  return collapseWhitespace()
      .split(' ')
      .map((word) => word.capitalize())
      .join(' ');
}