@@ -66,12 +66,45 @@ class FormBuilderState extends FormState {
66
66
}*/
67
67
68
68
class FormBuilder extends StatefulWidget {
69
- //final BuildContext context;
70
- final Function (Map <String , dynamic >) onChanged;
69
+ /// Called when one of the form fields changes.
70
+ ///
71
+ /// In addition to this callback being invoked, all the form fields themselves
72
+ /// will rebuild.
73
+ final VoidCallback onChanged;
74
+
75
+ /// Enables the form to veto attempts by the user to dismiss the [ModalRoute]
76
+ /// that contains the form.
77
+ ///
78
+ /// If the callback returns a Future that resolves to false, the form's route
79
+ /// will not be popped.
80
+ ///
81
+ /// See also:
82
+ ///
83
+ /// * [WillPopScope] , another widget that provides a way to intercept the
84
+ /// back button.
71
85
final WillPopCallback onWillPop;
86
+
87
+ /// The widget below this widget in the tree.
88
+ ///
89
+ /// This is the root of the widget hierarchy that contains this form.
90
+ ///
91
+ /// {@macro flutter.widgets.child}
72
92
final Widget child;
93
+
94
+ /// Whether the field value can be changed. Defaults to false.
95
+ /// If true, all form fields will not accept user input.
73
96
final bool readOnly;
97
+
98
+ /// If true, form fields will validate and update their error text
99
+ /// immediately after every change. Otherwise, you must call
100
+ /// [FormState.validate] to validate.
74
101
final bool autovalidate;
102
+
103
+ /// An optional Map of field initialValues. Keys correspond to the field's
104
+ /// attribute and value to the initialValue of the field.
105
+ ///
106
+ /// The initialValues set here will be ignored if the field has a local
107
+ /// initialValue set.
75
108
final Map <String , dynamic > initialValue;
76
109
77
110
const FormBuilder ({
@@ -135,16 +168,6 @@ class FormBuilderState extends State<FormBuilder> {
135
168
_fieldKeys.remove (attribute);
136
169
}
137
170
138
- /*changeAttributeValue(String attribute, dynamic newValue) {
139
- print(this.fieldKeys[attribute]);
140
- if (this.fieldKeys[attribute] != null){
141
- print("Current $attribute value: ${this.fieldKeys[attribute].currentState.value}");
142
- print("Trying to change $attribute to $newValue");
143
- this.fieldKeys[attribute].currentState.didChange(newValue);
144
- print("$attribute value after: ${this.fieldKeys[attribute].currentState.value}");
145
- }
146
- }*/
147
-
148
171
void save () {
149
172
_formKey.currentState.save ();
150
173
}
@@ -172,9 +195,7 @@ class FormBuilderState extends State<FormBuilder> {
172
195
),
173
196
autovalidate: widget.autovalidate,
174
197
onWillPop: widget.onWillPop,
175
- onChanged: () {
176
- widget.onChanged? .call (value);
177
- },
198
+ onChanged: widget.onChanged,
178
199
);
179
200
}
180
201
}
0 commit comments