27 lines
671 B
Dart
27 lines
671 B
Dart
import 'package:intl/intl.dart';
|
|
|
|
extension StringExt on String {
|
|
int get toIntegerFromText {
|
|
final cleanedText = replaceAll(RegExp(r'[^0-9]'), '');
|
|
final parsedValue = int.tryParse(cleanedText) ?? 0;
|
|
return parsedValue;
|
|
}
|
|
|
|
String get currencyFormatRpV2 {
|
|
final parsedValue = int.tryParse(this) ?? 0;
|
|
return NumberFormat.currency(
|
|
locale: 'id',
|
|
symbol: 'Rp ',
|
|
decimalDigits: 0,
|
|
).format(parsedValue);
|
|
}
|
|
|
|
String toTitleCase() {
|
|
if (isEmpty) return '';
|
|
return split(' ').map((word) {
|
|
if (word.isEmpty) return '';
|
|
return word[0].toUpperCase() + word.substring(1).toLowerCase();
|
|
}).join(' ');
|
|
}
|
|
}
|