How to detect keyboard events on TextFormField in Flutter? If the user deletes the last letter and presses the delete button again, the cursor should jump back to the previous TextFormField.
I would like to implement a pin-enter screen, something like that one.
https://mobile-solutions.ingenico.com/wp-content/uploads/IMG_022.png
For text entry, consider using a EditableText, which integrates with on-screen keyboards and input method editors (IMEs). Creates a widget that receives raw keyboard events. For text entry, consider using a EditableText, which integrates with on-screen keyboards and input method editors (IMEs).
onChange
And FocusScope
for set focusHere when you delete last letter of second FormField
focus set on first FormField
var firstField = FocusNode();
var secondField = FocusNode();
@override
Widget build(BuildContext context) {
return Column(children: <Widget>[
TextFormField(
focusNode: firstField,
onChanged: (text) {
print("First field: $text");
},
),
TextFormField(
focusNode: secondField,
onChanged: (text) {
if (text.length <= 0) {
FocusScope.of(context).requestFocus(firstField);
}
print("Second field: $text");
},
)
]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With