dart - Dart:获取指定语言环境的货币代码

标签 dart formatting currency

特定的Dart问题。给定语言环境(即'en_US''es_ES',...),如何获取关联的货币符号?

您是否知道Java中是否有类似于Currency的库? https://docs.oracle.com/javase/8/docs/api/java/util/Currency.html

最佳答案

您可以使用intl包(https://pub.dartlang.org/packages/intl)

import 'package:intl/intl.dart';

main() {
  var formatEnUs = NumberFormat.simpleCurrency(locale: 'en_US');
  print(formatEnUs.currencySymbol); // $
  print(formatEnUs.currencyName); // USD

  var formatEs = NumberFormat.simpleCurrency(locale: 'es_ES');
  print(formatEs.currencySymbol); // €
  print(formatEs.currencyName); // EUR
}

关于dart - Dart:获取指定语言环境的货币代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55809576/

相关文章:

flutter - Flutter使触摸事件通过AppBar传递

flutter - 带Cubit的DropDownButton

listview - 使用 ListView 时是否必须使用 ListTile?

python - 如何将 float 格式化为整数?

html - CSS float 不能正确定位 <div>

r - 在 R 中为卡方检验格式化数据

unit-testing - 我如何在Dart中的then语句中进行测试

wordpress - woocommerce 上的多种货币,可根据位置自动切换

ruby-on-rails - money-rails,Money#==仅支持零数字

PHP 货币格式尾随零