-
Notifications
You must be signed in to change notification settings - Fork 124
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
RangeError was thrown while dispatching notifications for MoneyMaskedTextController #57
Comments
Did you manage to solve? |
Eu resolvi. O erro acima parou de ser lançado ao mudar o código fonte do widget. O método numberValue estava assim: double get numberValue { parts.insert(parts.length - precision, '.'); return double.parse(parts.join()); e alterei de forma que ficasse assim: double get numberValue => double.parse(_getSanitizedText(this.text)) / 100.0; Foi preciso também, adicionar o método _getSanitizedText: String _getSanitizedText(String text) { var valuesToSanitize = [this.thousandSeparator, this.decimalSeparator]; valuesToSanitize.forEach((val) { cleanedText = _getOnlyNumbers(cleanedText); return cleanedText; |
The error was been caused when I have changed the text of MoneyMaskedTextController to blank text. I switch to: The error have disappeared. The downside is when I update the value "updateValue(0)" I get the mask 0,00 on the instead of blank TextField. I don't found a way to clean/reset the TextFiled with (X) suffix icon to reset my TextField. |
Following this as well, would really like a way to be able to call textController.clear() without getting this error while using the MoneyMaskedTextController. |
I am getting this exception when the MoneyMaskedTextController is set to blank ("")
flutter --version
Flutter 1.20.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision bbfbf1770c (11 days ago) • 2020-08-13 08:33:09 -0700
Engine • revision 9d5b21729f
Tools • Dart 2.9.1
flutter_masked_text: 0.8.0
Here is the initializer
_myMoneyField = MoneyMaskedTextController(
decimalSeparator: ',',
thousandSeparator: '.',
precision: 3,
initialValue: 1);
══╡ EXCEPTION CAUGHT BY FOUNDATION LIBRARY ╞════════════════════════════════════════════════════════
The following RangeError was thrown while dispatching notifications for MoneyMaskedTextController:
Invalid value: Only valid value is 0: -2
When the exception was thrown, this was the stack:
(elided 3 frames from dart:async)
The MoneyMaskedTextController sending notification was:
MoneyMaskedTextController#6f686(TextEditingValue(text: ┤├, selection: TextSelection(baseOffset:
-1, extentOffset: -1, affinity: TextAffinity.downstream, isDirectional: false), composing:
TextRange(start: -1, end: -1)))
The text was updated successfully, but these errors were encountered: