The method addListener() of the TextEditingController get called multiple times after executing the clear() method, this will only happen if we are clearing it.
TextEditingController _pinPutController = TextEditingController();
@override
void initState() {
_pinPutController.addListener(() {
if (_pinPutController.text.length > 4) {
print("Hello world");
_pinPutController.clear();
}
});
}
When the condition in the if statement is true, the body is executed twice.
Can anyone help me to solve this problem?