从语言代码很容易:
var format = NumberFormat.simpleCurrency(locale: "es"); print(format.currencySymbol);
但我只有EUR代表欧元,所以货币代码
EUR
pgx2nnw81#
var format = NumberFormat.simpleCurrency(locale: _language); <-- doesn't really what matter what language you pass print(format.simpleCurrencySymbol("EUR"));
zqdjd7g92#
intl软件包可以解决这个问题
import 'package:intl/intl.dart'; void currency() { Locale locale = Localizations.localeOf(context); var format = NumberFormat.simpleCurrency(locale: locale.toString()); print("CURRENCY SYMBOL ${format.currencySymbol}"); // $ print("CURRENCY NAME ${format.currencyName}"); // USD }
hkmswyz63#
试试这个:
NumberFormat().simpleCurrencySymbol('USF') // $
https://api.flutter.dev/flutter/intl/NumberFormat/simpleCurrencySymbol.html
3条答案
按热度按时间pgx2nnw81#
zqdjd7g92#
intl软件包可以解决这个问题
hkmswyz63#
试试这个:
https://api.flutter.dev/flutter/intl/NumberFormat/simpleCurrencySymbol.html