1
+ import 'dart:ui' ;
2
+
1
3
import 'package:flutter/material.dart' ;
2
4
import 'package:flutter_form_builder/flutter_form_builder.dart' ;
3
5
6
+ /// Demonstrates the use of itemDecorators to wrap a box around selection items
4
7
class DecoratedRadioCheckbox extends StatefulWidget {
5
8
const DecoratedRadioCheckbox ({Key ? key}) : super (key: key);
6
9
@@ -14,76 +17,114 @@ class _DecoratedRadioCheckboxState extends State<DecoratedRadioCheckbox> {
14
17
15
18
@override
16
19
Widget build (BuildContext context) {
17
- return FormBuilder (
20
+ return SingleChildScrollView (
21
+ child: FormBuilder (
18
22
key: _formKey,
19
23
child: Column (
20
24
children: < Widget > [
21
25
const SizedBox (height: 20 ),
22
26
// this text appears correctly if the textScaler <> 1.0
23
27
const Text (
24
- 'Checkboxes: control leading - with itemDecoration- label area is a column of Widgets - wrapSpacing 5.0' ,
28
+ 'With itemDecoration- label is a column of Widgets - orientation: wrap - wrapSpacing 5.0' ,
25
29
textScaler: TextScaler .linear (1.01 )),
26
30
FormBuilderCheckboxGroup (
27
- name: 'aCheckboxGroup ' ,
31
+ name: 'aCheckboxGroup1 ' ,
28
32
options: getDemoOptionsWidgets (),
29
33
wrapSpacing: 5.0 ,
30
34
itemDecoration: BoxDecoration (
31
- border: Border .all (color: Colors .blueAccent),
35
+ color: Colors .orange.shade200,
36
+ border: Border .all (color: Colors .blue),
32
37
borderRadius: BorderRadius .circular (5.0 )),
33
38
),
34
39
const SizedBox (height: 20 ),
35
40
const Text (
36
- 'Checkboxes: control trailing - with itemDecoration - label area is a column of Widgets - wrapSpacing 5.0' ,
41
+ 'With itemDecoration - label is a column of Widgets - orientation: wrap - wrapSpacing 5.0' ,
37
42
textScaler: TextScaler .linear (1.01 )),
38
43
FormBuilderCheckboxGroup (
39
- name: 'aCheckboxGroup ' ,
44
+ name: 'aCheckboxGroup2 ' ,
40
45
options: getDemoOptionsWidgets (),
41
46
wrapSpacing: 5.0 ,
42
47
controlAffinity: ControlAffinity .trailing,
43
48
itemDecoration: BoxDecoration (
49
+ color: Colors .amber.shade200,
44
50
border: Border .all (color: Colors .blueAccent),
45
51
borderRadius: BorderRadius .circular (5.0 )),
46
52
),
47
53
const SizedBox (height: 20 ),
48
54
const Text (
49
- 'Radio: control leading - with itemDecoration - label area is a column of Widgets - wrapSpacing 5.0' ,
55
+ 'With itemDecoration - label is a column of Widgets - orientation: wrap - wrapSpacing 5.0' ,
50
56
textScaler: TextScaler .linear (1.01 )),
51
57
FormBuilderRadioGroup (
52
- name: 'aRadioGroup ' ,
58
+ name: 'aRadioGroup1 ' ,
53
59
options: getDemoOptionsWidgets (),
54
60
wrapSpacing: 5.0 ,
55
61
itemDecoration: BoxDecoration (
62
+ color: Colors .green.shade200,
56
63
border: Border .all (color: Colors .blueAccent),
57
64
borderRadius: BorderRadius .circular (5.0 )),
58
65
),
59
66
const SizedBox (height: 20 ),
60
67
const Text (
61
- 'Radio: control leading - with itemDecoration - label area just the value - wrapSpacing 10.0' ,
68
+ 'With itemDecoration - label is the value - orientation: wrap - wrapSpacing 10.0' ,
62
69
textScaler: TextScaler .linear (1.01 )),
63
70
FormBuilderRadioGroup (
64
71
name: 'aRadioGroup2' ,
65
72
options: getDemoOptions (),
66
73
wrapSpacing: 10.0 ,
67
74
itemDecoration: BoxDecoration (
75
+ color: Colors .blueGrey.shade200,
68
76
border: Border .all (color: Colors .blueAccent),
69
77
borderRadius: BorderRadius .circular (5.0 )),
70
78
),
71
79
const SizedBox (height: 20 ),
72
80
const Text (
73
- 'Radio: control leading - no itemDecoration - label area just the value - wrapSpacing 10.0' ,
81
+ 'No itemDecoration - label is the value - orientation: wrap - wrapSpacing 10.0' ,
74
82
textScaler: TextScaler .linear (1.01 )),
75
-
76
83
FormBuilderRadioGroup (
77
- name: 'aRadioGroup2 ' ,
84
+ name: 'aRadioGroup3 ' ,
78
85
options: getDemoOptions (),
79
86
wrapSpacing: 10.0 ,
80
87
),
81
88
const SizedBox (height: 20 ),
89
+ const SizedBox (height: 20 ),
90
+ const Text (
91
+ 'With itemDecoration - orientation:horizontal - orientation: horiz - wrapSpacing 5.0' ,
92
+ textScaler: TextScaler .linear (1.01 )),
93
+ FormBuilderCheckboxGroup (
94
+ name: 'aCheckboxGroup3' ,
95
+ options: getDemoOptionsWidgets (),
96
+ wrapSpacing: 5.0 ,
97
+ orientation: OptionsOrientation .horizontal,
98
+ itemDecoration: BoxDecoration (
99
+ gradient:
100
+ const LinearGradient (colors: [Colors .red, Colors .white]),
101
+ border: Border .all (color: Colors .blueAccent),
102
+ borderRadius: BorderRadius .circular (5.0 )),
103
+ ),
104
+ const SizedBox (height: 20 ),
105
+ const Text (
106
+ 'With itemDecoration - orientation:vertical - orientation: vert - wrapSpacing 5.0' ,
107
+ textScaler: TextScaler .linear (1.01 )),
108
+ FormBuilderCheckboxGroup (
109
+ name: 'aCheckboxGroup3' ,
110
+ options: getDemoOptionsWidgets (),
111
+ wrapSpacing: 5.0 ,
112
+ orientation: OptionsOrientation .vertical,
113
+ itemDecoration: BoxDecoration (
114
+ gradient: const LinearGradient (
115
+ begin: Alignment .topCenter,
116
+ end: Alignment .bottomCenter,
117
+ colors: [Colors .red, Colors .white]),
118
+ color: Colors .red.shade100,
119
+ border: Border .all (color: Colors .blueAccent),
120
+ borderRadius: BorderRadius .circular (5.0 )),
121
+ ),
82
122
],
83
123
),
84
- );
124
+ )) ;
85
125
}
86
126
127
+ /// options using column of widgets for the label
87
128
List <FormBuilderFieldOption > getDemoOptionsWidgets () {
88
129
return const [
89
130
FormBuilderFieldOption (
@@ -105,6 +146,7 @@ class _DecoratedRadioCheckboxState extends State<DecoratedRadioCheckbox> {
105
146
];
106
147
}
107
148
149
+ /// opens using just values
108
150
List <FormBuilderFieldOption > getDemoOptions () {
109
151
return const [
110
152
FormBuilderFieldOption (
0 commit comments