capitalizeWords method

String capitalizeWords()

Capitalizes the first letter of each word in this string

Example:

print('hello world'.capitalizeWords()); // "Hello World"

Implementation

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