gtgalone / currency_text_input_formatter

Currency Text Input Formatter for Flutter.
https://pub.dev/packages/currency_text_input_formatter
MIT License
50 stars 29 forks source link

Handle parsing of null decimalDigits #64

Closed cosmopool closed 1 month ago

cosmopool commented 1 month ago

When creating a formatter with a null decimalDigits and using the formatString method, a TypeError is thrown because a non-null assertion operator is used when checking if decimalDigits is positive.

  num _parseStrToNum(String text) {
    num value = num.tryParse(text) ?? 0;
    // THIS LINE
    if (format.decimalDigits! > 0) {
      value /= pow(10, format.decimalDigits!);
    }
    return value;
  }
gtgalone commented 1 month ago

Awesome @cosmopool !

I just have released new version with your PR.

Thanks!