Skip to content

Commit 919955f

Browse files
committed
Fixed issue where DropdownButton hint overlaps with labelText. Closes #372
1 parent f55901f commit 919955f

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

lib/src/fields/form_builder_dropdown.dart

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,16 @@ class _FormBuilderDropdownState<T> extends State<FormBuilderDropdown<T>> {
121121
return InputDecorator(
122122
decoration: widget.decoration.copyWith(
123123
errorText: field.errorText,
124+
floatingLabelBehavior: widget.hint == null
125+
? widget.decoration.floatingLabelBehavior
126+
: FloatingLabelBehavior.always,
124127
),
125128
isEmpty: field.value == null,
126-
child: DropdownButtonHideUnderline(
127-
child: Row(
128-
mainAxisAlignment: MainAxisAlignment.start,
129-
children: <Widget>[
130-
Expanded(
129+
child: Row(
130+
mainAxisAlignment: MainAxisAlignment.start,
131+
children: <Widget>[
132+
Expanded(
133+
child: DropdownButtonHideUnderline(
131134
child: DropdownButton<T>(
132135
isExpanded: widget.isExpanded,
133136
hint: widget.hint,
@@ -163,19 +166,19 @@ class _FormBuilderDropdownState<T> extends State<FormBuilderDropdown<T>> {
163166
selectedItemBuilder: widget.selectedItemBuilder,
164167
),
165168
),
166-
if (widget.allowClear &&
167-
!widget.readOnly &&
168-
field.value != null) ...[
169-
const VerticalDivider(),
170-
InkWell(
171-
child: widget.clearIcon,
172-
onTap: () {
173-
_changeValue(field, null);
174-
},
175-
),
176-
],
169+
),
170+
if (widget.allowClear &&
171+
!widget.readOnly &&
172+
field.value != null) ...[
173+
const VerticalDivider(),
174+
InkWell(
175+
child: widget.clearIcon,
176+
onTap: () {
177+
_changeValue(field, null);
178+
},
179+
),
177180
],
178-
),
181+
],
179182
),
180183
);
181184
},

0 commit comments

Comments
 (0)