Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a679ee7

Browse files
Update README.md
1 parent 50051b0 commit a679ee7

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

‎README.md‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,51 @@ A new Flutter project using `Form()`. This form uses `focusNode:`.
77
This is actually not a complete project, in this repository, I showed how to implement a form correctly with the focus node.
88

99
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+
Form(
12+
key: _formGlobalKey,
13+
child: Padding(
14+
padding: const EdgeInsets.all(16.0),
15+
child: Column(
16+
children: <Widget>[
17+
18+
TextFormField(
19+
focusNode: _textFocusNode1,
20+
textInputAction: TextInputAction.next,
21+
onFieldSubmitted: (_) {
22+
// PASS THE FOCUS NODE TO NEXT FIELD
23+
FocusScope.of(context).requestFocus(_textFocusNode2);
24+
},
25+
),
26+
27+
TextFormField(
28+
focusNode: _textFocusNode2,
29+
textInputAction: TextInputAction.next,
30+
onFieldSubmitted: (_) {
31+
// DON'T HAVE NEXT TEXT FIELD, UNFOCUS FOCUS-NODE
32+
_textFocusNode2.unfocus(),
33+
},
34+
35+
),
36+
37+
DropdownButtonFormField(
38+
39+
...
40+
41+
onChanged: (value) {
42+
setState(() {
43+
FocusScope.of(context).requestFocus(new FocusNode());
44+
_selectedText = value;
45+
});
46+
},
47+
...
48+
),
49+
50+
],
51+
),
52+
),
53+
),
54+
```
1055

1156
Putting this on the dropdown will unfocus all active focus node.
1257

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /