Full width DropdownButton with adjust dropdown arrow icon in Flutter

Question

Asked by Sandip P on August 14, 2018 (source).

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,
)

Answer

Question answered by Pablo C (source).

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
        );
  }
DART FLUTTER WIDGET
SHARE: