titleCase method

String titleCase()

Capitalizes the first character of each word in a string.

Implementation

String titleCase() {
  if (this == null) {
    throw ArgumentError('string: $this');
  }
  if (this!.isEmpty) {
    return '';
  }
  return this!.split(' ').map((word) => word.capitalize()).join(' ');
}