Skip to content

Commit 07c45a8

Browse files
committed
set the off side margin to be the same as the wrapOffset when using the itemDecoration
1 parent c94ec60 commit 07c45a8

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

lib/src/fields/form_builder_checkbox_group.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ class FormBuilderCheckboxGroup<T> extends FormBuilderFieldDecoration<List<T>> {
2525
final ControlAffinity controlAffinity;
2626
final OptionsOrientation orientation;
2727

28-
/// A decorator that is applied to each select item - ex: box the item
28+
/// A BoxDecoration that is added to each item if provided
29+
/// WrapSpacing is reused for the the padding inside the itemDecoration
30+
/// on the side opposite from the control
2931
final BoxDecoration? itemDecoration;
3032

3133
/// Creates a list of Checkboxes for selecting multiple options

lib/src/fields/form_builder_radio_group.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ class FormBuilderRadioGroup<T> extends FormBuilderFieldDecoration<T> {
2222
final WrapAlignment wrapRunAlignment;
2323
final WrapCrossAlignment wrapCrossAxisAlignment;
2424

25-
/// A decorator that is applied to each select item - ex: box the item
25+
/// A BoxDecoration that is added to each item if provided
26+
/// WrapSpacing is reused for the the padding inside the itemDecoration
27+
/// on the side opposite from the control
2628
final BoxDecoration? itemDecoration;
2729

2830
/// Creates field to select one value from a list of Radio Widgets

lib/src/widgets/grouped_checkbox.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,9 @@ class GroupedCheckbox<T> extends StatelessWidget {
181181

182182
final ControlAffinity controlAffinity;
183183

184-
/// will be added to each item if provided
184+
/// A BoxDecoration that is added to each item if provided
185+
/// WrapSpacing is reused for the the padding inside the itemDecoration
186+
/// on the side opposite from the control
185187
final BoxDecoration? itemDecoration;
186188

187189
const GroupedCheckbox({
@@ -304,6 +306,11 @@ class GroupedCheckbox<T> extends StatelessWidget {
304306

305307
if (this.itemDecoration != null) {
306308
compositeItem = Container(
309+
padding: EdgeInsets.only(
310+
left:
311+
controlAffinity == ControlAffinity.leading ? 0.0 : wrapSpacing,
312+
right:
313+
controlAffinity == ControlAffinity.leading ? wrapSpacing : 0.0),
307314
decoration: this.itemDecoration,
308315
child: compositeItem,
309316
);

lib/src/widgets/grouped_radio.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,9 @@ class GroupedRadio<T> extends StatefulWidget {
172172

173173
final ControlAffinity controlAffinity;
174174

175-
/// will be added to each item if provided
175+
/// A BoxDecoration that is added to each item if provided
176+
/// WrapSpacing is reused for the the padding inside the itemDecoration
177+
/// on the side opposite from the control
176178
final BoxDecoration? itemDecoration;
177179

178180
const GroupedRadio({
@@ -297,6 +299,13 @@ class _GroupedRadioState<T> extends State<GroupedRadio<T?>> {
297299
if (widget.itemDecoration != null) {
298300
compositeItem = Container(
299301
decoration: widget.itemDecoration,
302+
padding: EdgeInsets.only(
303+
left: widget.controlAffinity == ControlAffinity.leading
304+
? 0.0
305+
: widget.wrapSpacing,
306+
right: widget.controlAffinity == ControlAffinity.leading
307+
? widget.wrapSpacing
308+
: 0.0),
300309
child: compositeItem,
301310
);
302311
}

0 commit comments

Comments
 (0)