app working with sandbox
This commit is contained in:
@@ -57,3 +57,31 @@ String labelForThemeMode(ThemeMode mode) {
|
||||
ThemeMode.system => 'System',
|
||||
};
|
||||
}
|
||||
|
||||
/// Formats a money amount with currency code, e.g. `1 234,56 EUR`.
|
||||
String formatMoney(double amount, String currency) {
|
||||
final sign = amount < 0 ? '-' : '';
|
||||
final abs = amount.abs();
|
||||
final fixed = abs.toStringAsFixed(2);
|
||||
final parts = fixed.split('.');
|
||||
final whole = parts[0];
|
||||
final fraction = parts.length > 1 ? parts[1] : '00';
|
||||
|
||||
final buffer = StringBuffer();
|
||||
for (var i = 0; i < whole.length; i++) {
|
||||
final fromEnd = whole.length - i;
|
||||
buffer.write(whole[i]);
|
||||
if (fromEnd > 1 && fromEnd % 3 == 1) {
|
||||
buffer.write('\u00a0');
|
||||
}
|
||||
}
|
||||
return '$sign${buffer.toString()},$fraction $currency';
|
||||
}
|
||||
|
||||
/// Formats an ISO date string (`yyyy-MM-dd` or full ISO) for list rows.
|
||||
String formatIsoDate(String raw) {
|
||||
if (raw.isEmpty) return '';
|
||||
final parsed = DateTime.tryParse(raw);
|
||||
if (parsed == null) return raw;
|
||||
return formatDate(parsed);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user