Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 767
Paras Dhawan Avatar asked Oct 27 '25 17:10

Paras Dhawan


1 Answers

Set isExpanded property of DropdownButton to true

isExpanded: true

Like that:

DropdownButtonHideUnderline(
            child: DropdownButton<String>(
              isExpanded: true,
              items: [...]
like image 52
shadowsheep Avatar answered Oct 30 '25 10:10

shadowsheep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!