revanced-manager/lib/utils/string.dart

9 lines
288 B
Dart
Raw Normal View History

2022-08-06 15:04:18 +02:00
extension StringCasingExtension on String {
String toCapitalized() =>
length > 0 ? '${this[0].toUpperCase()}${substring(1).toLowerCase()}' : '';
String toTitleCase() => replaceAll(RegExp(' +'), ' ')
.split(' ')
.map((str) => str.toCapitalized())
.join(' ');
}