Flutter: how to get currency symbol from currency code

Viewed 623

From language code it's easy:

var format = NumberFormat.simpleCurrency(locale: "es");
print(format.currencySymbol);

But the only thing I have is EUR for euro, so the currency code

2 Answers
var format = NumberFormat.simpleCurrency(locale: _language); <-- doesn't really what matter what language you pass
print(format.simpleCurrencySymbol("EUR"));

intl package does the trick

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
}
Related