Want to detect Keyboard event in flutter? Yes you can do that using onChange And FocusScope for set focus. Here when you delete last letter of second FormField focus set on first FormField.
Here is an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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 like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.