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

Library unusable on Dutch locale #18

Open LugonjaAleksandar opened 4 years ago

LugonjaAleksandar commented 4 years ago

When switching away from regular number format seen in English locale, to for example Dutch there is an issue with "flutter_money_formatter_base.dart" file that crashes when trying to parse a number that can't be parsed. Specific line that crashes is:

crashScreenshot

.format(num.parse(numerics));

To Reproduce Steps to reproduce the behavior:

  1. Enter decimal value and switch to Dutch locale in Flutter app

Expected behavior I expect that locale for decimal and thousands separator is respected, but I get crash.

Smartphone (please complete the following information):

autlunatic commented 4 years ago

On german Locale it also shows this error. I have found out that at least one Problem lies in the BaseCompact Format function in the utilities unit:

 NumberFormat get baseCompact =>
      this.settings.compactFormatType == CompactFormatType.short
          ? NumberFormat.compact()
          : NumberFormat.compactLong();

In my simple test it was working when i force the locale of en_US on the NumberFormat constructors

NumberFormat get baseCompact =>
     this.settings.compactFormatType == CompactFormatType.short
         ? NumberFormat.compact(locale:'en_US')
         : NumberFormat.compactLong(locale:'en_US');