例如 +100286020524,17 如何成为 Rp 100.286.020.524,17 并删除此符号 + 。如何在 Dart 中实现
编辑
这个mycode
我使用印度尼西亚语:1.0.1包
main() {
rupiah(123456789); // Rp 123,456,789
}
我已经试过像这样:
replaceAll(new RegExp(r'[^\w\s]+'),'')
但我不希望输出。
如何删除符号加
最佳答案
为了轻松根据语言环境设置值的格式,建议使用intl。
印度尼西亚的货币可以这样格式化:
double d = 100286020524.17;
final currencyFormatter = NumberFormat.currency(locale: 'ID');
print(currencyFormatter.format(d)); // IDR100.286.020.524,17
您还可以使用经典格式:
double d = 100286020524.17;
final currencyFormatter = NumberFormat('#,##0.00', 'ID');
print(currencyFormatter.format(d)); // 100.286.020.524,17
通过第二种方法,您将只格式化了没有货币符号的值。
关于flutter - Flutter转换货币格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60164145/