Skip to content

Commit fa662b5

Browse files
committed
If disabled dropdown has value, show value instead of disabledHint
1 parent 0de64e5 commit fa662b5

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## [3.2.6] - 06-Jul-2019
2+
* If disabled dropdown has value, show value instead of `disabledHint`
3+
14
## [3.2.5] - 05-Jul-2019
25
* Fixed Stack Overflow bug in `setAttributeValue` function
36

example/lib/main.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ class MyHomePageState extends State<MyHomePage> {
186186
FormBuilderDropdown(
187187
attribute: "gender",
188188
decoration: InputDecoration(labelText: "Gender"),
189-
// initialValue: 'Male',
189+
initialValue: 'Male',
190+
readonly: true,
190191
hint: Text('Select Gender'),
191192
validators: [FormBuilderValidators.required()],
192193
items: ['Male', 'Female', 'Other']

lib/src/fields/form_builder_dropdown.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
8484
} else
8585
_formState?.setAttributeValue(widget.attribute, val);
8686
},
87+
8788
builder: (FormFieldState<dynamic> field) {
8889
return InputDecorator(
8990
decoration: widget.decoration.copyWith(
@@ -97,7 +98,7 @@ class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
9798
value: field.value,
9899
style: widget.style,
99100
isDense: widget.isDense,
100-
disabledHint: widget.disabledHint,
101+
disabledHint: field.value != null ? Text("${field.value.toString()}") : widget.disabledHint,
101102
elevation: widget.elevation,
102103
iconSize: widget.iconSize,
103104
underline: widget.underline,
@@ -109,6 +110,9 @@ class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
109110
if (widget.onChanged != null) widget.onChanged(value);
110111
},
111112
//TODO: add icon, enabledColor, disabledColor
113+
/*icon: widget.icon,
114+
iconEnabledColor: widget.iconEnabledColor,
115+
iconDisabledColor: widget.iconDisabledColor,*/
112116
),
113117
);
114118
},

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_form_builder
22
description: Package to build Material Form with fields like TextField, DropDown, Switches etc. with ability to create custom FormFields and composability and reuse validation functions.
3-
version: 3.2.5
3+
version: 3.2.6
44
author: Danvick Miller <[email protected]>
55
homepage: https://github.com/danvick/flutter_form_builder
66

0 commit comments

Comments
 (0)