Paras Dhawan
Paras Dhawan

Reputation: 374

Flutter dropdown button text overflow

How can i make the text expand to it's content? I Tried this

child: DropdownButtonHideUnderline(
                                  child: DropdownButton<String>(
                                items: _currentCitySelected.area
                                    .map((String dropDownStringItem) {
                                  return DropdownMenuItem<String>(
                                    value: dropDownStringItem,
                                    child: Container(
                                        child: Text(
                                      dropDownStringItem,
                                      maxLines: 2,
//                                      overflow: TextOverflow.clip,
                                    )),
                                  );
                                }).toList(),
                                onChanged: (String newValueSelected) {
                                  setState(() {
                                    this._currentAreaSelected =
                                        newValueSelected;
                                  });
                                },
                                value: _currentAreaSelected,
                              ))

[enter image description here Text expands to content in drop down dialog content, but it does'nt works the same way in the main view. enter image description here

Upvotes: 4

Views: 3662

Answers (1)

shadowsheep
shadowsheep

Reputation: 15002

Set isExpanded property of DropdownButton to true

isExpanded: true

Like that:

DropdownButtonHideUnderline(
            child: DropdownButton<String>(
              isExpanded: true,
              items: [...]

Upvotes: 10

Related Questions