特定的Dart问题。给定语言环境(即'en_US'
,'es_ES'
,...),如何获取关联的货币符号?
您知道Java中是否有类似于Currency
的库? https://docs.oracle.com/javase/8/docs/api/java/util/Currency.html
答案 0 :(得分:1)
您可以使用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
}