drop-down-menu - Flutter 下拉按钮文字溢出

标签 drop-down-menu flutter

我怎样才能使文本扩展到它的内容?我试过了

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 文本扩展为下拉对话框内容中的内容,但它在主视图中的工作方式不同。 enter image description here

最佳答案

DropdownButtonisExpanded 属性设置为 true

isExpanded: true

像那样:

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

关于drop-down-menu - Flutter 下拉按钮文字溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54275923/

相关文章:

html - 子菜单重叠主菜单项

javascript - 鬼场不消鬼

css - 有没有一种方法可以在纯 CSS 中的父主体内部/之上显示下拉菜单

php - 根据下拉列表使用数据库值动态更新 div

Flutter 在滚动 ListView 上显示和隐藏容器

Flutter Bloc Todo 示例 - 监听存储库中的单个待办事项

PHP 下拉选中

firebase - 如何在 Scoped Model 中从 Firestore 获取数据 - Flutter

flutter - Flutter接收Future数据(SharedPreferences)的问题

flutter - 必须向 Text 小部件提供非空字符串。错误