Skip to content

Commit 8541f82

Browse files
committed
Added more options for DropdownButton. Closes #153, #337
1 parent 349f043 commit 8541f82

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

lib/src/fields/form_builder_dropdown.dart

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ class FormBuilderDropdown extends StatefulWidget {
2626
final bool allowClear;
2727
final Widget clearIcon;
2828
final FormFieldSetter onSaved;
29+
final double itemHeight;
30+
final Color focusColor;
31+
final Color dropdownColor;
32+
final bool autofocus;
33+
final FocusNode focusNode;
34+
final VoidCallback onTap;
35+
final List<Widget> Function(BuildContext) selectedItemBuilder;
2936

3037
FormBuilderDropdown({
3138
Key key,
@@ -51,6 +58,13 @@ class FormBuilderDropdown extends StatefulWidget {
5158
this.allowClear = false,
5259
this.clearIcon = const Icon(Icons.close),
5360
this.onSaved,
61+
this.itemHeight,
62+
this.focusColor,
63+
this.dropdownColor,
64+
this.autofocus = false,
65+
this.focusNode,
66+
this.onTap,
67+
this.selectedItemBuilder,
5468
}) : super(key: key) /*: assert(allowClear == true || clearIcon != null)*/;
5569

5670
@override
@@ -107,8 +121,10 @@ class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
107121
decoration: widget.decoration.copyWith(
108122
errorText: field.errorText,
109123
),
124+
isEmpty: field.value == null,
110125
child: DropdownButtonHideUnderline(
111126
child: Row(
127+
mainAxisAlignment: MainAxisAlignment.start,
112128
children: <Widget>[
113129
Expanded(
114130
child: DropdownButton(
@@ -136,6 +152,13 @@ class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
136152
: (value) {
137153
_changeValue(field, value);
138154
},
155+
itemHeight: widget.itemHeight,
156+
focusColor: widget.focusColor,
157+
dropdownColor: widget.dropdownColor,
158+
autofocus: widget.autofocus,
159+
focusNode: widget.focusNode,
160+
onTap: widget.onTap,
161+
selectedItemBuilder: widget.selectedItemBuilder,
139162
),
140163
),
141164
if (widget.allowClear &&
@@ -148,7 +171,7 @@ class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
148171
_changeValue(field, null);
149172
},
150173
),
151-
]
174+
],
152175
],
153176
),
154177
),

0 commit comments

Comments
 (0)