Это что-то вроде хака, но он дает вам полный контроль над тем, как выглядит выпадающий список, короче говоря, make value: null, hint: null, iconsize: null, создать стек с двумя контейнерами одинакового размера:1, который отображает ваш свернутый раскрывающийся список, и 1, который обнаруживает жесты «развернуть».
class MyDropdownFilled extends StatefulWidget {
final List<String> dropDownValues;
const MyDropdownFilled({Key key, @required this.dropDownValues})
: super(key: key);
List<DropdownMenuItem<String>> getDropDownMenuItems() {
return dropDownValues
.map((itemString) =>
DropdownMenuItem(child: Text(itemString), value: itemString))
.toList();
}
@override
_MyDropdownFilledState createState() => _MyDropdownFilledState();
}
class _MyDropdownFilledState extends State<MyDropdownFilled> {
String _activeDropdown;
@override
initState() {
super.initState();
_activeDropdown = widget.dropDownValues[0];
}
@override
Widget build(BuildContext context) {
return Stack(
children: [
Container(
width: double.infinity,
padding: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: primaryColor.shade600,
borderRadius: BorderRadius.all(Radius.circular(2))),
child:
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Text(_activeDropdown, style: Theme.of(context).textTheme.caption),
Icon(Icons.arrow_drop_down, size: 30, color: Colors.white),
]),
),
Container(
width: double.infinity,
padding: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: Colors.transparent,
borderRadius: BorderRadius.all(Radius.circular(2))),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
value: null,
isDense: true,
iconSize: 0,
hint: null,
onChanged: (String newValue) {
setState(() {
_activeDropdown = newValue;
});
},
items: widget.dropDownValues.map((String value) {
return DropdownMenuItem(
value: value,
child: Text(value),
);
}).toList(),
)),
)
],
);
}
}