Vaani/lib/shared/extensions/enum.dart
Dr.Blank b229c4f2f5
feat: add shake detection functionality (#36)
* feat: add shake detection functionality and integrate vibration support

* feat: add shake detector settings page
2024-09-28 01:27:56 -04:00

25 lines
630 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(' ');
}
}