capitalizeEach property

String get capitalizeEach

Capitalizes the first letter of each word in the string.

Implementation

String get capitalizeEach {
  if (isEmpty) return this;

  return split(' ').map((String word) {
    return word.isNotEmpty ? '${word[0].toUpperCase()}${word.substring(1).toLowerCase()}' : word;
  }).join(' ');
}