Vaani/lib/shared/extensions/enum.dart
Dr.Blank e23c0b6c5f
Some checks are pending
Flutter CI & Release / Test (push) Waiting to run
Flutter CI & Release / Build Android APKs (push) Blocked by required conditions
Flutter CI & Release / build_linux (push) Blocked by required conditions
Flutter CI & Release / Create GitHub Release (push) Blocked by required conditions
chore: run dart format
2026-01-10 16:51:05 +05:30

22 lines
599 B
Dart

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
.replaceAllMapped(RegExp(r'([A-Z])'), (match) => ' ${match.group(0)}')
.trim()
.split(' ')
.map((word) => word[0].toUpperCase() + word.substring(1))
.join(' ');
}
}