toTitleCase method

String toTitleCase()

Converts the string to Title Case.

Example:

'hello world'.toTitleCase(); // 'Hello World'
'foo_bar'.toTitleCase(); // 'Foo Bar'

Implementation

String toTitleCase() => words()
    .map((String word) =>
        word[0].toUpperCase() + word.substring(1).toLowerCase())
    .join(' ');