23 lines
559 B
Dart
23 lines
559 B
Dart
AmountParts splitAmount(String value) {
|
|
final trimmed = value.trim();
|
|
if (trimmed.isEmpty || trimmed == '-') {
|
|
return const AmountParts(amount: '-', currency: '');
|
|
}
|
|
final parts = trimmed.split(' ');
|
|
if (parts.length < 2) {
|
|
return AmountParts(amount: trimmed, currency: '');
|
|
}
|
|
final currency = parts.removeLast();
|
|
return AmountParts(amount: parts.join(' '), currency: currency);
|
|
}
|
|
|
|
class AmountParts {
|
|
final String amount;
|
|
final String currency;
|
|
|
|
const AmountParts({
|
|
required this.amount,
|
|
required this.currency,
|
|
});
|
|
}
|