|
1 | 1 | # Flutter Form with Focus Node |
2 | 2 |
|
3 | | -A new Flutter project using Form(). This form uses focus node. |
| 3 | +A new Flutter project using `Form()`. This form uses `focusNode:`. |
4 | 4 |
|
5 | 5 | ## Getting Started |
6 | 6 |
|
7 | | -This is actually not a complete project, in this repository, I showed how to implement a form correctly with focus node. |
| 7 | +This is actually not a complete project, in this repository, I showed how to implement a form correctly with the focus node. |
| 8 | + |
| 9 | +This project demonstrates how `TextFormFields()` communicate with each other, how to pass `FocusNode()` instance to any `TextFormFields()`. Also, it handles all active focus nodes by clicking dropdown menu. |
| 10 | + |
| 11 | +Putting this on the dropdown will unfocus all active focus node. |
| 12 | + |
| 13 | +``` |
| 14 | +onChanged: (value) { |
| 15 | + setState(() { |
| 16 | + // Will unfocus other fields, otherwise after selecting |
| 17 | + // a value last active focus node will be focused |
| 18 | + FocusScope.of(context).requestFocus(new FocusNode()); |
| 19 | + _selectedText = value; |
| 20 | + }); |
| 21 | +}, |
| 22 | +``` |
8 | 23 |
|
9 | 24 |
|
10 | 25 | ## Preview |
|
0 commit comments