Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in CurrencyInputFormatter #92

Closed
alex9153 opened this issue Sep 4, 2022 · 2 comments
Closed

Bug in CurrencyInputFormatter #92

alex9153 opened this issue Sep 4, 2022 · 2 comments

Comments

@alex9153
Copy link

alex9153 commented Sep 4, 2022

CurrencyInputFormatter(thousandSeparator: ThousandSeparator.Space, mantissaLength: 0, trailingSymbol: " $")

mantissaLength is 0 and if I tap on dot TextField stops reaction on any typing.

@caseyryan
Copy link
Owner

Thanks. I'll check it

@caseyryan
Copy link
Owner

I could not reproduce this (maybe because of a difference environment) but I've found out that it throws an "out of range exception" in this code when I press period at the end of the line:

return oldValue.copyWith(
        selection: TextSelection.collapsed(
          offset: oldCaretIndex + 1,
        ),
      );

Maybe it was the reason of the bug you've described.

So I've replaced the code with this

return oldValue.copyWith(
        selection: TextSelection.collapsed(
          offset: min(
            oldValue.text.length,
            oldCaretIndex + 1,
          ),
        ),
      );

And the exception has gone

caseyryan added a commit that referenced this issue Sep 7, 2022
caseyryan added a commit that referenced this issue Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants