Skip to content

Commit 798a92e

Browse files
committed
use wrapSpacing for horiz and vert orientations
1 parent aa92c59 commit 798a92e

File tree

3 files changed

+42
-17
lines changed

3 files changed

+42
-17
lines changed

example/lib/sources/decorated_radio_checkbox.dart

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,39 +86,47 @@ class _DecoratedRadioCheckboxState extends State<DecoratedRadioCheckbox> {
8686
wrapSpacing: 10.0,
8787
),
8888
const SizedBox(height: 20),
89-
const SizedBox(height: 20),
9089
const Text(
91-
'With itemDecoration - orientation:horizontal - orientation: horiz - wrapSpacing 5.0',
90+
'With itemDecoration - orientation: horiz - no border - wrapSpacing 5.0',
9291
textScaler: TextScaler.linear(1.01)),
9392
FormBuilderCheckboxGroup(
9493
name: 'aCheckboxGroup3',
9594
options: getDemoOptionsWidgets(),
9695
wrapSpacing: 5.0,
9796
orientation: OptionsOrientation.horizontal,
9897
itemDecoration: BoxDecoration(
99-
gradient:
100-
const LinearGradient(colors: [Colors.red, Colors.white]),
101-
border: Border.all(color: Colors.blueAccent),
98+
color: Colors.grey.shade300,
99+
// border: Border.all(color: Colors.blueAccent),
102100
borderRadius: BorderRadius.circular(5.0)),
103101
),
104102
const SizedBox(height: 20),
105103
const Text(
106-
'With itemDecoration - orientation:vertical - orientation: vert - wrapSpacing 5.0',
104+
'With itemDecoration - orientation: vert - with border - wrapSpacing 5.0',
107105
textScaler: TextScaler.linear(1.01)),
108106
FormBuilderCheckboxGroup(
109107
name: 'aCheckboxGroup3',
110108
options: getDemoOptionsWidgets(),
111109
wrapSpacing: 5.0,
112110
orientation: OptionsOrientation.vertical,
113111
itemDecoration: BoxDecoration(
114-
gradient: const LinearGradient(
115-
begin: Alignment.topCenter,
116-
end: Alignment.bottomCenter,
117-
colors: [Colors.red, Colors.white]),
118112
color: Colors.red.shade100,
119113
border: Border.all(color: Colors.blueAccent),
120114
borderRadius: BorderRadius.circular(5.0)),
121115
),
116+
const SizedBox(height: 20),
117+
const Text(
118+
'With itemDecoration - orientation: vert - with border - wrapSpacing 5.0',
119+
textScaler: TextScaler.linear(1.01)),
120+
FormBuilderRadioGroup(
121+
name: 'aRadioGroup4',
122+
options: getDemoOptionsWidgets(),
123+
wrapSpacing: 5.0,
124+
orientation: OptionsOrientation.vertical,
125+
itemDecoration: BoxDecoration(
126+
color: Colors.lightBlue.shade100,
127+
border: Border.all(color: Colors.blueAccent),
128+
borderRadius: BorderRadius.circular(5.0)),
129+
),
122130
],
123131
),
124132
));

lib/src/widgets/grouped_checkbox.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ class GroupedCheckbox<T> extends StatelessWidget {
182182
final ControlAffinity controlAffinity;
183183

184184
/// A BoxDecoration that is added to each item if provided
185-
/// WrapSpacing is reused for the the padding inside the itemDecoration
185+
/// [wrapSpacing] is reused for the the padding inside the [itemDecoration].
186+
/// [wrapSpacing] is used as inter-item bottom margin for [Orientation.vertical]
187+
/// [wrapSpacing] is used as inter-item right margin for [Orientation.horizontal].
186188
/// on the side opposite from the control
187189
final BoxDecoration? itemDecoration;
188190

@@ -306,12 +308,17 @@ class GroupedCheckbox<T> extends StatelessWidget {
306308

307309
if (this.itemDecoration != null) {
308310
compositeItem = Container(
309-
padding: EdgeInsets.only(
310-
left:
311-
controlAffinity == ControlAffinity.leading ? 0.0 : wrapSpacing,
312-
right:
313-
controlAffinity == ControlAffinity.leading ? wrapSpacing : 0.0),
314311
decoration: this.itemDecoration,
312+
padding: EdgeInsets.only(
313+
left: controlAffinity == ControlAffinity.leading ? 0.0 : wrapSpacing,
314+
right: controlAffinity == ControlAffinity.leading ? wrapSpacing : 0.0,
315+
),
316+
margin: EdgeInsets.only(
317+
bottom:
318+
orientation == OptionsOrientation.vertical ? wrapSpacing : 0.0,
319+
right:
320+
orientation == OptionsOrientation.horizontal ? wrapSpacing : 0.0,
321+
),
315322
child: compositeItem,
316323
);
317324
}

lib/src/widgets/grouped_radio.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ class GroupedRadio<T> extends StatefulWidget {
173173
final ControlAffinity controlAffinity;
174174

175175
/// A BoxDecoration that is added to each item if provided
176-
/// WrapSpacing is reused for the the padding inside the itemDecoration
176+
/// [wrapSpacing] is reused for the the padding inside the [itemDecoration].
177+
/// [wrapSpacing] is used as inter-item bottom margin for [Orientation.vertical]
178+
/// [wrapSpacing] is used as inter-item right margin for [Orientation.horizontal].
177179
/// on the side opposite from the control
178180
final BoxDecoration? itemDecoration;
179181

@@ -306,6 +308,14 @@ class _GroupedRadioState<T> extends State<GroupedRadio<T?>> {
306308
right: widget.controlAffinity == ControlAffinity.leading
307309
? widget.wrapSpacing
308310
: 0.0),
311+
margin: EdgeInsets.only(
312+
bottom: widget.orientation == OptionsOrientation.vertical
313+
? widget.wrapSpacing
314+
: 0.0,
315+
right: widget.orientation == OptionsOrientation.horizontal
316+
? widget.wrapSpacing
317+
: 0.0,
318+
),
309319
child: compositeItem,
310320
);
311321
}

0 commit comments

Comments
 (0)