currencyFormatWithSymbol method
通用货币格式化方法(带符号) print(15000.currencyFormatWithSymbol("¥")); // ¥ 150
Implementation
// print(15000.currencyFormatWithSymbol("$", autoMoneyUnit: true)); // $ 150.00
String currencyFormatWithSymbol(String symbol, {bool autoMoneyUnit = false}) {
if (this == null) {
return '$symbol 0.00';
}
final resultAmount = this! / 100;
String formatted;
if (autoMoneyUnit) {
formatted = _formatPrice(resultAmount);
} else {
formatted = resultAmount.toStringAsFixed(2);
}
return '$symbol $formatted';
}