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

Hi, I proposed this change for MoneyMaskedTextController for better UX #49

Open
x4080 opened this issue Jan 15, 2020 · 1 comment
Open

Comments

@x4080
Copy link

x4080 commented Jan 15, 2020

@flutter_masked_text.dart

double get numberValue {
    if (this.text == '') return 0;
    List<String> parts = [];
    if (this.text.length == 1 && this.text!=decimalSeparator && this.text!=thousandSeparator) {
      for (var i = 0; i < precision - this.text.length; i++) {
        parts.insert(parts.length, "0");
      }
      parts.insert(parts.length, this.text);
    } else
      parts = _getOnlyNumbers(this.text).split('').toList(growable: true);
    if (parts.length >= precision)
      parts.insert(parts.length - precision, decimalSeparator);
    return double.parse(parts.join());
  }

Improvements :

  • No more errors
  • When typing from empty value it will fix automagically
  • Using thousandSeparator and decimalSeparator variables

Thanks

@x4080
Copy link
Author

x4080 commented Jan 16, 2020

And this part also

    this.addListener(() {
      this.updateValue(this.numberValue);
      // this.afterChange(this.text, this.numberValue); --> empty function
    });

azabazay added a commit to TheRedBricks/flutter-masked-text that referenced this issue Feb 28, 2020
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

1 participant