toTitleCase function
Converts a snake_case or camelCase string to a human-readable title. e.g. product_card → Product Card, coverImage → Cover Image
Implementation
String toTitleCase(String input) {
if (input.isEmpty) return '';
return toSnakeCase(input)
.split('_')
.map((w) => w.isEmpty ? '' : w[0].toUpperCase() + w.substring(1))
.join(' ');
}