@@ -3,69 +3,6 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
3
3
4
4
typedef ValueTransformer <T > = dynamic Function (T value);
5
5
6
- /*class FormBuilder extends Form {
7
- @override
8
- final VoidCallback onChanged;
9
- @override
10
- final WillPopCallback onWillPop;
11
- @override
12
- final Widget child;
13
- @override
14
- final bool autovalidate;
15
- final bool readOnly;
16
- final Map<String, dynamic> initialValue;
17
-
18
- const FormBuilder({
19
- Key key,
20
- @required this.child,
21
- this.autovalidate = false,
22
- this.onWillPop,
23
- this.onChanged,
24
- this.readOnly,
25
- this.initialValue = const {},
26
- }) : super(
27
- key: key,
28
- autovalidate: autovalidate,
29
- child: child,
30
- onChanged: onChanged,
31
- onWillPop: onWillPop,
32
- );
33
-
34
- static FormBuilderState of(BuildContext context) =>
35
- context.findAncestorStateOfType<FormBuilderState>();
36
- }
37
-
38
- class FormBuilderState extends FormState {
39
- @override
40
- FormBuilder get widget => super.widget;
41
-
42
- Map<String, dynamic> _value;
43
-
44
- Map<String, dynamic> get value => {...widget.initialValue ?? {}, ..._value};
45
-
46
- Map<String, dynamic> get initialValue => widget.initialValue;
47
-
48
- bool get readOnly => widget.readOnly;
49
-
50
- @override
51
- void initState() {
52
- super.initState();
53
- // _fieldKeys = {};
54
- _value = {};
55
- }
56
-
57
- void updateFormAttributeValue(String name, dynamic value) {
58
- setState(() {
59
- _value = {..._value, name: value};
60
- });
61
- }
62
-
63
- bool saveAndValidate() {
64
- save();
65
- return validate();
66
- }
67
- }*/
68
-
69
6
class FormBuilder extends StatefulWidget {
70
7
/// Called when one of the form fields changes.
71
8
///
@@ -109,6 +46,14 @@ class FormBuilder extends StatefulWidget {
109
46
/// initialValue set.
110
47
final Map <String , dynamic > initialValue;
111
48
49
+ /// Whether the form should ignore submitting values from readOnly fields.
50
+ /// This behavior is common in HTML forms where readonly values are not
51
+ /// submitted when the form is submitted.
52
+ ///
53
+ /// If true, in the final form value, there will be no values for readOnly
54
+ /// fields
55
+ final bool skipReadOnly;
56
+
112
57
const FormBuilder ({
113
58
Key key,
114
59
@required this .child,
@@ -117,6 +62,7 @@ class FormBuilder extends StatefulWidget {
117
62
this .autovalidateMode,
118
63
this .onWillPop,
119
64
this .initialValue = const {},
65
+ this .skipReadOnly = false ,
120
66
}) : super (key: key);
121
67
122
68
static FormBuilderState of (BuildContext context) =>
0 commit comments