apskel-pos-flutter-v2/lib/common/extension/string_extension.dart

25 lines
560 B
Dart
Raw Normal View History

2025-10-26 16:09:56 +07:00
part of 'extension.dart';
extension StringX on String {
2025-10-26 23:10:23 +07:00
String toTitleCase() {
if (isEmpty) return '';
return split(' ')
.map((word) {
if (word.isEmpty) return '';
return word[0].toUpperCase() + word.substring(1).toLowerCase();
})
.join(' ');
}
2025-10-26 16:09:56 +07:00
TableStatusType toTableStatusType() {
switch (this) {
case 'available':
return TableStatusType.available;
case 'occupied':
return TableStatusType.occupied;
default:
return TableStatusType.unknown;
}
}
}