withCapitalizedWords method
Capitalizes each word in the string, assuming words are separated by spaces, hyphens, or underscores.
Implementation
String withCapitalizedWords() {
if (trim().isEmpty) return '';
// FIX: Added '_' to the regex to correctly handle snake_case inputs.
return trim()
.split(RegExp(r'[\s-_]+'))
.where((e) => e.isNotEmpty)
.map((e) => e.toLowerCase().capitalize())
.join(' ');
}