toTitleCase method

String toTitleCase()

Converts the string to title case.

hello world -> Hello World

Implementation

String toTitleCase() => replaceAll(RegExp(' +'), ' ')
    .split(' ')
    .map((str) => str.toCapitalized())
    .join(' ');