Open roland-jungwirth opened 5 years ago
Storing the Controller
in a global variable worked for me.
class _LoginPageState extends State<LoginPage> {
MaskedTextController controller = MaskedTextController(mask: '000.000.000-00');
@override
Widget build(BuildContext context) {
...
}
Widget _buildCampoCPF() {
return Container(
margin: EdgeInsets.only(top: 20.0),
child: TextFormField(
controller: controller,
...
),
);
}
Got the idea from issue #13
Storing the controller in a variable did not work for me
EDIT: What did work was making the Widget stateful instead of stateless
Similarly to the closed issue, I am having a problem when clicking on the "Done" button. The displayed value is reset to the initial value (0.00 in most cases) when using the MoneyMaskedTextController. I can reproduce this on iPhone 5 and Android simulated and on a 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.
This is my implementation of the issue (I have stripped out unnecessary containers, etc. but I have tested it and it does the same):