@@ -10,9 +10,6 @@ class FormBuilder extends StatefulWidget {
10
10
/// will rebuild.
11
11
final VoidCallback ? onChanged;
12
12
13
- /// DEPRECATED: Use [onPopInvokedWithResult] instead.
14
- final void Function (bool )? onPopInvoked;
15
-
16
13
/// {@macro flutter.widgets.navigator.onPopInvokedWithResult}
17
14
///
18
15
/// {@tool dartpad}
@@ -105,11 +102,6 @@ class FormBuilder extends StatefulWidget {
105
102
required this .child,
106
103
this .onChanged,
107
104
this .autovalidateMode,
108
- @Deprecated (
109
- 'Use onPopInvokedWithResult instead. '
110
- 'This feature was deprecated after v3.22.0-12.0.pre.' ,
111
- )
112
- this .onPopInvoked,
113
105
this .onPopInvokedWithResult,
114
106
this .initialValue = const < String , dynamic > {},
115
107
this .skipDisabled = false ,
@@ -143,6 +135,7 @@ class FormBuilderState extends State<FormBuilder> {
143
135
/// Only used to internal logic
144
136
bool get focusOnInvalid => _focusOnInvalid;
145
137
138
+ /// Get if form is enabled
146
139
bool get enabled => widget.enabled;
147
140
148
141
/// Verify if all fields on form are valid.
@@ -171,6 +164,7 @@ class FormBuilderState extends State<FormBuilder> {
171
164
/// Get all fields of form.
172
165
FormBuilderFields get fields => _fields;
173
166
167
+ /// Get all fields values of form.
174
168
Map <String , dynamic > get instantValue => Map <String , dynamic >.unmodifiable (
175
169
_instantValue.map (
176
170
(key, value) => MapEntry (
@@ -204,15 +198,18 @@ class FormBuilderState extends State<FormBuilder> {
204
198
initialValue[name];
205
199
}
206
200
201
+ /// Get a field value by name
207
202
void setInternalFieldValue <T >(String name, T ? value) {
208
203
_instantValue[name] = value;
209
204
widget.onChanged? .call ();
210
205
}
211
206
207
+ /// Remove a field value by name
212
208
void removeInternalFieldValue (String name) {
213
209
_instantValue.remove (name);
214
210
}
215
211
212
+ /// Register a field on form
216
213
void registerField (String name, FormBuilderFieldState field) {
217
214
// Each field must have a unique name. Ideally we could simply:
218
215
// assert(!_fields.containsKey(name));
@@ -242,6 +239,7 @@ class FormBuilderState extends State<FormBuilder> {
242
239
);
243
240
}
244
241
242
+ /// Unregister a field on form
245
243
void unregisterField (String name, FormBuilderFieldState field) {
246
244
assert (
247
245
_fields.containsKey (name),
@@ -270,23 +268,14 @@ class FormBuilderState extends State<FormBuilder> {
270
268
}
271
269
}
272
270
271
+ /// Save form values
273
272
void save () {
274
273
_formKey.currentState! .save ();
275
274
// Copy values from instant to saved
276
275
_savedValue.clear ();
277
276
_savedValue.addAll (_instantValue);
278
277
}
279
278
280
- @Deprecated (
281
- 'Will be remove to avoid redundancy. Use fields[name]?.invalidate(errorText) instead' )
282
- void invalidateField ({required String name, String ? errorText}) =>
283
- fields[name]? .invalidate (errorText ?? '' );
284
-
285
- @Deprecated (
286
- 'Will be remove to avoid redundancy. Use fields.first.invalidate(errorText) instead' )
287
- void invalidateFirstField ({required String errorText}) =>
288
- fields.values.first.invalidate (errorText);
289
-
290
279
/// Validate all fields of form
291
280
///
292
281
/// Focus to first invalid field when has field invalid, if [focusOnInvalid] is `true` .
@@ -343,7 +332,7 @@ class FormBuilderState extends State<FormBuilder> {
343
332
);
344
333
}
345
334
346
- /// Reset form to `initialValue`
335
+ /// Reset form to `initialValue` set on FormBuilder or on each field.
347
336
void reset () {
348
337
_formKey.currentState? .reset ();
349
338
}
@@ -376,8 +365,6 @@ class FormBuilderState extends State<FormBuilder> {
376
365
key: _formKey,
377
366
autovalidateMode: widget.autovalidateMode,
378
367
onPopInvokedWithResult: widget.onPopInvokedWithResult,
379
- // ignore: deprecated_member_use
380
- onPopInvoked: widget.onPopInvoked,
381
368
canPop: widget.canPop,
382
369
// `onChanged` is called during setInternalFieldValue else will be called early
383
370
child: _FormBuilderScope (
0 commit comments