fadhly-permata / flutter_money_formatter

"FlutterMoneyFormatter" is a Flutter extension to formatting various types of currencies according to the characteristics you like, without having to be tied to any localization.
https://pub.dartlang.org/packages/flutter_money_formatter
Other
85 stars 106 forks source link

Default money symbol is hardcoded to $ #38

Open michelemazzei opened 1 year ago

michelemazzei commented 1 year ago

Hi, the MoneyFormatter settings loads the default symbol as '$' , so if the user does not specify it, the $ symbol is used.

If you write the following instruction: MoneyFormatter(amount: 1000).output.symbolOnLeft;

The result would be: $ 1,000 But, if your locale is , for example, it_IT, the currency should be €. Of course, you could easly bypass the problem , but it is easer to let the MoneyFormatterSettings class to discover the user's locale settings.

Thus I suggest you to change the MoneyFormatterSettings as follows:

MoneyFormatterSettings({ this.symbol, this.thousandSeparator = ',', this.decimalSeparator = '.', this.symbolAndNumberSeparator = ' ', this.fractionDigits = 2, this.compactFormatType = CompactFormatType.short, }) { symbol ??= NumberFormat.simpleCurrency().currencySymbol; }

In this manner the current symbol is correctly set to €.