Closed dwolfhub closed 5 years ago
Hi!
Sorry, I can't reproduce this issue. Probably was fixed in flutter.
I created a video trying to reproduce and ask for more information:
Yep- I can no longer replicate after updating flutter to newest beta.
Thanks!
This bug is happening with me. Flutter version: 1.1.9 dev Dart version: 2.1.1
flutter_masked_text version: 0.7.0
Also happening to me. The text field is cleared after dismissing the keyboard. Tested with the same code @dwolfhub wrote.
Flutter 1.0.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5391447fae (3 months ago) • 2018-11-29 19:41:26 -0800
Engine • revision 7375a0f414
Tools • Dart 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
EDIT: I figured out why this was happening, the controller instance must be stored in a variable. The code below simulates the problem.
TextField(
decoration: new InputDecoration(
labelText: 'Value'
),
keyboardType: TextInputType.number,
controller: MoneyMaskedTextController(),
)
The workaround is to store the controller instance:
MoneyMaskedTextController _valueController = MoneyMaskedTextController();
TextField(
decoration: new InputDecoration(
labelText: 'Value'
),
keyboardType: TextInputType.number,
controller: _valueController,
)
@benhurott, thanks for making this! Ok, I can reproduce this on iPhone 5 and Android simulated and on my Samsung s10. I've stripped all my logic out of the code and still the issue happens. Should you need more information, please feel free to check in.
Putting the controller in a variable (global or local) doesn't fix this for me. Here's what I'm using:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.2 18C54, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.1)y long time...⢿
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.5)
[!] IntelliJ IDEA Community Edition (version 2019.1.3)
✗ Flutter plugin not installed; this adds Flutter specific functionality.
[✓] VS Code (version 1.37.1)
[✓] Connected device (3 available)
In case this helps anyone, I fixed this in the following way:
MoneyMaskedTextController _valueController = MoneyMaskedTextController();
_valueController.afterChange = (String previous, String next) {
_valueController.updateValue(double.parse(next));
};
I too face the same issue of value get disappeared in flutter on clicking the checkmark. Can you please help to figure it out?
I got the solution. Thank you...
The checkmark button on the keyboard should just remove the cursor from the field and hide the keyboard. Not sure why it's clearing the value from the input. Note: happens with other keyboardTypes as well.
On flutter beta channel, flutter_masked_text 0.6.0