@@ -21,67 +21,73 @@ class _CustomFieldsState extends State<CustomFields> {
21
21
key: _formKey,
22
22
child: Column (
23
23
children: < Widget > [
24
+ const SizedBox (height: 20 ),
24
25
FormBuilderField <String ?>(
25
26
name: 'name' ,
26
- onChanged: (val) => debugPrint (val.toString ()),
27
27
builder: (FormFieldState field) {
28
- return Row (
29
- crossAxisAlignment: CrossAxisAlignment .center,
30
- children: [
31
- const Expanded (child: Text ('Name' ), flex: 1 ),
32
- Expanded (
33
- flex: 2 ,
34
- child: InputDecorator (
35
- decoration: InputDecoration (
36
- errorText: field.errorText,
37
- border: InputBorder .none,
38
- contentPadding: EdgeInsets .zero),
39
- child: CupertinoTextField (
40
- onChanged: (value) => field.didChange (value),
41
- ),
42
- ),
43
- ),
44
- ],
28
+ return CupertinoTextField (
29
+ onChanged: (value) => field.didChange (value),
45
30
);
46
31
},
47
- autovalidateMode: AutovalidateMode .always,
48
- validator: (valueCandidate) {
49
- if (valueCandidate? .isEmpty ?? true ) {
50
- return 'This field is required.' ;
51
- }
52
- return null ;
32
+ ),
33
+ const SizedBox (height: 10 ),
34
+ FormBuilderField <bool >(
35
+ name: 'terms' ,
36
+ builder: (FormFieldState field) {
37
+ return CheckboxListTile (
38
+ title: const Text ('I Accept the terms and conditions' ),
39
+ value: false ,
40
+ controlAffinity: ListTileControlAffinity .leading,
41
+ onChanged: (value) => field.didChange (value),
42
+ );
53
43
},
54
44
),
45
+ const SizedBox (height: 10 ),
55
46
FormBuilderField <String ?>(
56
- name: "option" ,
47
+ name: 'name' ,
48
+ builder: (FormFieldState field) {
49
+ return CupertinoFormRow (
50
+ prefix: const Text ('Name: ' ),
51
+ error:
52
+ field.errorText != null ? Text (field.errorText! ) : null ,
53
+ child: CupertinoTextField (
54
+ onChanged: (value) => field.didChange (value),
55
+ ),
56
+ );
57
+ },
58
+ autovalidateMode: AutovalidateMode .always,
57
59
validator: (valueCandidate) {
58
60
if (valueCandidate? .isEmpty ?? true ) {
59
61
return 'This field is required.' ;
60
62
}
61
63
return null ;
62
64
},
63
- builder: (FormFieldState <String ?> field) {
65
+ ),
66
+ const SizedBox (height: 10 ),
67
+ FormBuilderField <bool >(
68
+ name: 'terms' ,
69
+ builder: (FormFieldState field) {
64
70
return InputDecorator (
65
71
decoration: InputDecoration (
66
- labelText: "Select option" ,
67
- contentPadding:
68
- const EdgeInsets .only (top: 10.0 , bottom: 0.0 ),
69
- border: InputBorder .none,
72
+ labelText: 'Terms' ,
70
73
errorText: field.errorText,
71
74
),
72
- child: SizedBox (
73
- height: 200 ,
74
- child: CupertinoPicker (
75
- itemExtent: 30 ,
76
- children: options.map ((c) => Text (c)).toList (),
77
- onSelectedItemChanged: (index) {
78
- field.didChange (options[index]);
79
- },
80
- ),
75
+ child: CheckboxListTile (
76
+ title: const Text ('I Accept the terms and conditions' ),
77
+ controlAffinity: ListTileControlAffinity .leading,
78
+ value: false ,
79
+ onChanged: (value) => field.didChange (value),
81
80
),
82
81
);
83
82
},
83
+ validator: (valueCandidate) {
84
+ if (valueCandidate != true ) {
85
+ return 'Accept terms and conditions to continue.' ;
86
+ }
87
+ return null ;
88
+ },
84
89
),
90
+ const SizedBox (height: 10 ),
85
91
Row (
86
92
children: < Widget > [
87
93
Expanded (
0 commit comments