Setting the Width for a Dropdown Button You can set the width for a DropdownButton by setting its isExpanded parameter to true and wrapping it inside a fixed-size Container or SIzedBox.
To change dropdown arrow color in Flutter, you can add the same arrow icon inside the icon property and change the color using the color property. Here are the steps: Inside the DropdownButton widget, add the icon parameter and assign the Icon widget. Inside the Icon widget, add the Icons.
If we want to display some other text instead of the selected option on the button we will use selectedItemBuilder. DropdownButton( value: _value, selectedItemBuilder: (BuildContext context) { return list_items. map<Widget>((int item) { return Text('item $item'); }). toList(); }, items: list_items.
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
);
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With