@@ -31,7 +31,7 @@ class FormBuilderDropdown extends StatefulWidget {
31
31
this .readOnly = false ,
32
32
this .decoration = const InputDecoration (),
33
33
this .isExpanded = true ,
34
- this .isDense = false ,
34
+ this .isDense = true ,
35
35
this .elevation = 8 ,
36
36
this .iconSize = 24.0 ,
37
37
this .hint,
@@ -99,38 +99,70 @@ class _FormBuilderDropdownState extends State<FormBuilderDropdown> {
99
99
return InputDecorator (
100
100
decoration: widget.decoration.copyWith (
101
101
errorText: field.errorText,
102
- border: InputBorder .none,
103
102
),
104
- child: DropdownButton (
105
- isExpanded: widget.isExpanded,
106
- hint: widget.hint,
107
- items: widget.items,
108
- value: field.value,
109
- style: widget.style,
110
- isDense: widget.isDense,
111
- disabledHint: field.value != null
112
- ? Text ("${field .value .toString ()}" )
113
- : widget.disabledHint,
114
- elevation: widget.elevation,
115
- iconSize: widget.iconSize,
116
- icon: widget.icon,
117
- iconDisabledColor: widget.iconDisabledColor,
118
- iconEnabledColor: widget.iconEnabledColor,
119
- underline: widget.underline,
120
- onChanged: _readOnly
121
- ? null
122
- : (value) {
123
- FocusScope .of (context).requestFocus (FocusNode ());
124
- field.didChange (value);
125
- if (widget.onChanged != null ) widget.onChanged (value);
126
- },
127
- //TODO: add icon, enabledColor, disabledColor
128
- /*icon: widget.icon,
129
- iconEnabledColor: widget.iconEnabledColor,
130
- iconDisabledColor: widget.iconDisabledColor,*/
103
+ child: DropdownButtonHideUnderline (
104
+ child: DropdownButton (
105
+ isExpanded: widget.isExpanded,
106
+ hint: widget.hint,
107
+ items: widget.items,
108
+ value: field.value,
109
+ style: widget.style,
110
+ isDense: widget.isDense,
111
+ disabledHint: field.value != null
112
+ ? Text ("${field .value .toString ()}" )
113
+ : widget.disabledHint,
114
+ elevation: widget.elevation,
115
+ iconSize: widget.iconSize,
116
+ icon: widget.icon,
117
+ iconDisabledColor: widget.iconDisabledColor,
118
+ iconEnabledColor: widget.iconEnabledColor,
119
+ underline: widget.underline,
120
+ onChanged: _readOnly
121
+ ? null
122
+ : (value) {
123
+ FocusScope .of (context).requestFocus (FocusNode ());
124
+ field.didChange (value);
125
+ if (widget.onChanged != null ) widget.onChanged (value);
126
+ },
127
+ ),
131
128
),
132
129
);
133
130
},
134
131
);
135
132
}
133
+
134
+ /*@override
135
+ Widget build(BuildContext context) {
136
+ _readOnly = (_formState?.readOnly == true) ? true : widget.readOnly;
137
+
138
+ return DropdownButtonFormField(
139
+ key: _fieldKey,
140
+ decoration: widget.decoration.copyWith(
141
+ enabled: _readOnly ? false : true,
142
+ ),
143
+ hint: widget.hint,
144
+ items: widget.items,
145
+ value: _initialValue,
146
+ onChanged: _readOnly
147
+ ? null
148
+ : (value) {
149
+ FocusScope.of(context).requestFocus(FocusNode());
150
+ if (widget.onChanged != null) widget.onChanged(value);
151
+ },
152
+ validator: (val) {
153
+ for (int i = 0; i < widget.validators.length; i++) {
154
+ if (widget.validators[i](val) != null)
155
+ return widget.validators[i](val);
156
+ }
157
+ return null;
158
+ },
159
+ onSaved: (val) {
160
+ if (widget.valueTransformer != null) {
161
+ var transformed = widget.valueTransformer(val);
162
+ _formState?.setAttributeValue(widget.attribute, transformed);
163
+ } else
164
+ _formState?.setAttributeValue(widget.attribute, val);
165
+ },
166
+ );
167
+ }*/
136
168
}
0 commit comments