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

Not Working after certain amount is entered #35

Closed cgonzalezandrades closed 2 years ago

cgonzalezandrades commented 2 years ago

https://user-images.githubusercontent.com/11892778/184501116-a37c6ae7-dd7d-4afe-a97e-5afece4eeaee.mov

I know this is a ridiculous big number but is still worth fixing.


currency_text_input_formatter: ^2.1.7```
MikeRzDev commented 2 years ago

this is because this library uses NumberFormat.currency that uses 64-bit int, this int has a limit of 9,223,372,036,854,775,807 as this library uses this method internally to parse values an Overflow occurs. so the only fix for now would be that you limit the max number of chars to 18 if you include '.' are 23 max, OR implement your own formatting solution without using NumberFormat.currency. if you take the max char limit approach your implementation should look like this:

TextField (
...
inputFormatters: <TextInputFormatter>[
                          LengthLimitingTextInputFormatter(23),
                          CurrencyTextInputFormatter(symbol: '', decimalDigits: 0) // Or your config
                        ],
)
gtgalone commented 2 years ago

@MikeRzDev Thank you for your answer!

I will close it. We can reopen. if needed.