2024-09-28 01:27:56 -04:00
|
|
|
extension TitleCase on Enum {
|
|
|
|
|
String get properName {
|
|
|
|
|
final name = toString().split('.').last;
|
|
|
|
|
return name[0].toUpperCase() + name.substring(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String get titleCase {
|
|
|
|
|
return name
|
|
|
|
|
.replaceAllMapped(RegExp(r'([A-Z])'), (match) => ' ${match.group(0)}')
|
|
|
|
|
.trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String get pascalCase {
|
|
|
|
|
// capitalize the first letter of each word
|
|
|
|
|
return name
|
2026-01-10 16:51:05 +05:30
|
|
|
.replaceAllMapped(RegExp(r'([A-Z])'), (match) => ' ${match.group(0)}')
|
2024-09-28 01:27:56 -04:00
|
|
|
.trim()
|
|
|
|
|
.split(' ')
|
|
|
|
|
.map((word) => word[0].toUpperCase() + word.substring(1))
|
|
|
|
|
.join(' ');
|
|
|
|
|
}
|
|
|
|
|
}
|