toTitleCase method
Title-cases this string.
wordSeparators is used to separate words if separators
is not given.
'camelCase'.toTitleCase(); // 'Camel Case'
'PascalCase'.toTitleCase(); // 'Pascal Case'
'SCREAMING_CASE'.toTitleCase(); // 'SCREAMING CASE'
'documenting HTML code'.toTitleCase(); // 'Documenting HTML Code'
'snake_case'.toTitleCase(); // 'Snake Case'
'kebab-case'.toTitleCase(); // 'Kebab Case'
'Title Case'.toTitleCase(); // 'Title Case'
'Sentence case'.toTitleCase(); // 'Sentence Case'
Implementation
@useResult String toTitleCase([Pattern? separators]) => split(separators ?? wordSeparators)
.where((e) => e.isNotEmpty)
.map((e) => e.capitalize())
.join(' ');