Skip to content

Commit e88c10d

Browse files
committed
Added contentPadding option to Checkbox, CheckboxList, Radio and Switch to allow spacing of items in list options. Closes #280
1 parent da96d41 commit e88c10d

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

lib/src/fields/form_builder_checkbox.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class FormBuilderCheckbox extends StatefulWidget {
1919
final MaterialTapTargetSize materialTapTargetSize;
2020
final bool tristate;
2121
final FormFieldSetter onSaved;
22+
final EdgeInsets contentPadding;
2223

2324
FormBuilderCheckbox({
2425
Key key,
@@ -36,6 +37,7 @@ class FormBuilderCheckbox extends StatefulWidget {
3637
this.materialTapTargetSize,
3738
this.tristate = false,
3839
this.onSaved,
40+
this.contentPadding = const EdgeInsets.all(0.0),
3941
}) : super(key: key);
4042

4143
@override
@@ -129,7 +131,7 @@ class _FormBuilderCheckboxState extends State<FormBuilderCheckbox> {
129131
child: ListTile(
130132
dense: true,
131133
isThreeLine: false,
132-
contentPadding: EdgeInsets.all(0.0),
134+
contentPadding: widget.contentPadding,
133135
title: widget.label,
134136
leading: _leading(field),
135137
trailing: _trailing(field),

lib/src/fields/form_builder_checkbox_list.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ class FormBuilderCheckboxList extends StatefulWidget {
1010
final InputDecoration decoration;
1111
final ValueChanged onChanged;
1212
final ValueTransformer valueTransformer;
13+
final FormFieldSetter onSaved;
1314

1415
final List<FormBuilderFieldOption> options;
1516
final bool leadingInput;
1617
final Color activeColor;
1718
final Color checkColor;
1819
final MaterialTapTargetSize materialTapTargetSize;
1920
final bool tristate;
20-
final FormFieldSetter onSaved;
21+
final EdgeInsets contentPadding;
2122

2223
FormBuilderCheckboxList({
2324
Key key,
@@ -35,6 +36,7 @@ class FormBuilderCheckboxList extends StatefulWidget {
3536
this.materialTapTargetSize,
3637
this.tristate = false,
3738
this.onSaved,
39+
this.contentPadding = const EdgeInsets.all(0.0),
3840
}) : super(key: key);
3941

4042
@override
@@ -133,7 +135,7 @@ class _FormBuilderCheckboxListState extends State<FormBuilderCheckboxList> {
133135
ListTile(
134136
dense: true,
135137
isThreeLine: false,
136-
contentPadding: EdgeInsets.all(0.0),
138+
contentPadding: widget.contentPadding,
137139
leading: _leading(field, i),
138140
trailing: _trailing(field, i),
139141
title: widget.options[i],

lib/src/fields/form_builder_radio.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ class FormBuilderRadio extends StatefulWidget {
1010
final InputDecoration decoration;
1111
final ValueChanged onChanged;
1212
final ValueTransformer valueTransformer;
13-
final bool leadingInput;
1413

14+
final bool leadingInput;
1515
final List<FormBuilderFieldOption> options;
16-
1716
final MaterialTapTargetSize materialTapTargetSize;
18-
1917
final Color activeColor;
2018
final FormFieldSetter onSaved;
19+
final EdgeInsets contentPadding;
2120

2221
FormBuilderRadio({
2322
Key key,
@@ -33,6 +32,7 @@ class FormBuilderRadio extends StatefulWidget {
3332
this.materialTapTargetSize,
3433
this.activeColor,
3534
this.onSaved,
35+
this.contentPadding = const EdgeInsets.all(0.0),
3636
}) : super(key: key);
3737

3838
@override
@@ -123,7 +123,7 @@ class _FormBuilderRadioState extends State<FormBuilderRadio> {
123123
ListTile(
124124
dense: true,
125125
isThreeLine: false,
126-
contentPadding: EdgeInsets.all(0.0),
126+
contentPadding: widget.contentPadding,
127127
leading: _leading(field, i),
128128
title: widget.options[i],
129129
trailing: _trailing(field, i),

lib/src/fields/form_builder_switch.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class FormBuilderSwitch extends StatefulWidget {
6262
/// {@macro flutter.cupertino.switch.dragStartBehavior}
6363
final DragStartBehavior dragStartBehavior;
6464
final FormFieldSetter onSaved;
65+
final EdgeInsets contentPadding;
6566

6667
FormBuilderSwitch({
6768
Key key,
@@ -82,6 +83,7 @@ class FormBuilderSwitch extends StatefulWidget {
8283
this.materialTapTargetSize,
8384
this.dragStartBehavior = DragStartBehavior.start,
8485
this.onSaved,
86+
this.contentPadding = const EdgeInsets.all(0.0),
8587
}) : super(key: key);
8688

8789
@override
@@ -148,7 +150,7 @@ class _FormBuilderSwitchState extends State<FormBuilderSwitch> {
148150
child: ListTile(
149151
dense: true,
150152
isThreeLine: false,
151-
contentPadding: EdgeInsets.all(0.0),
153+
contentPadding: widget.contentPadding,
152154
title: widget.label,
153155
trailing: Switch(
154156
value: field.value,

0 commit comments

Comments
 (0)