File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class MyHomePageState extends State<MyHomePage> {
27
27
var data;
28
28
bool autoValidate = true ;
29
29
bool readOnly = false ;
30
+ GlobalKey <FormBuilderState > _fbKey = GlobalKey ();
30
31
31
32
@override
32
33
Widget build (BuildContext context) {
@@ -298,7 +299,7 @@ class MyHomePageState extends State<MyHomePage> {
298
299
"Zambia" ,
299
300
"Zimbabwe"
300
301
];
301
- GlobalKey < FormBuilderState > _fbKey = GlobalKey ();
302
+
302
303
return Scaffold (
303
304
appBar: AppBar (
304
305
title: Text ('Flutter FormBuilder Example' ),
@@ -310,7 +311,7 @@ class MyHomePageState extends State<MyHomePage> {
310
311
Expanded (
311
312
child: FormBuilder (
312
313
context,
313
- // key: _fbKey,
314
+ key: _fbKey,
314
315
autovalidate: autoValidate,
315
316
readonly: readOnly,
316
317
// showResetButton: true,
@@ -555,6 +556,7 @@ class MyHomePageState extends State<MyHomePage> {
555
556
MaterialButton (
556
557
child: Text ('External submit' ),
557
558
onPressed: () {
559
+ print (_fbKey);
558
560
_fbKey.currentState.save ();
559
561
if (_fbKey.currentState.validate ()) {
560
562
print (_fbKey.currentState.value);
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ class FormBuilderState extends State<FormBuilder> {
132
132
hintText: formControl.hint,
133
133
helperText: formControl.hint,
134
134
),
135
- autovalidate: formControl.autovalidate,
135
+ autovalidate: formControl.autovalidate ?? false ,
136
136
initialValue:
137
137
formControl.value != null ? "${formControl .value }" : '' ,
138
138
maxLines:
You can’t perform that action at this time.
0 commit comments