Full width DropdownButton with adjust dropdown arrow icon in Flutter
DartWidgetFlutterDart Problem Overview
I needed to add DropdownButton with full width with adjust dropdown arrow icon in Flutter as well. But with many tried it in many ways but it doesn't expand its width full.
This is my code for DropdownButton
:
new Expanded(
child: new Column(
children: <Widget>[
new DropdownButton(
items: [
new DropdownMenuItem(child: new Text("Abc")),
new DropdownMenuItem(child: new Text("Xyz")),
],
hint: new Text("Select City"),
onChanged: null
)
]
),
flex: 1,
)
Dart Solutions
Solution 1 - Dart
Just adding isExpanded:true
to the DropdownButton
Widget example() {
return new DropdownButton(
isExpanded: true,
items: [
new DropdownMenuItem(child: new Text("Abc")),
new DropdownMenuItem(child: new Text("Xyz")),
],
hint: new Text("Select City"),
onChanged: null
);
}
Solution 2 - Dart
Try to add the following in the Column you have...
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
...
)
You should not need the Expanded
widget as that would try to fill the vertical space and not the horizontal (width) space.