extended_masked_text icon indicating copy to clipboard operation
extended_masked_text copied to clipboard

FormatException: Invalid number (at character 1)

Open codegrue opened this issue 4 years ago • 2 comments

With the following code I get this error:

MoneyMaskedTextController?  moneyController = MoneyMaskedTextController(
          decimalSeparator: '.',
          thousandSeparator: ',');

moneyController!.updateValue(45.67);

codegrue avatar Mar 22 '21 18:03 codegrue

Can you provide the stack-trace or a minimal sample project? I was unable to reproduce this error with the provided code.

LeandroNovak avatar Mar 26 '21 20:03 LeandroNovak

In debugging your code I realized you have a try/catch in the flow, and I had break on All Exceptions enabled, so this was being reported to me as a crash. I will close this as designed, but maybe there's a better way to detect the issue.

The exact line of code is:

(money_masked_text_controller.dart line 142) var numberOfLeadingZeros = text.length - int.parse(text).toString().length;

If text is "" the int.parse will error. I think this should be changed to int?.parse

codegrue avatar Mar 29 '21 12:03 codegrue