【问题标题】:Dropdown button not expanding下拉按钮未展开
【发布时间】:2021-09-17 03:52:57
【问题描述】:

我正在尝试使用带有 4 个项目的 DropdownButtonFormField 构建一个表单,但我不知道为什么它不想扩展。

加了isDense : true不是因为太小了

这是按钮代码

new Container(
    child: DropdownButtonFormField(
        isDense: false,
        hint: Text('Ecole'),
        onSaved: (value) {
            this._data.ecole = value.toString();
           },
        items: ['HEI', 'ISEN', 'ISA', 'all'].map((String value) {
            return DropdownMenuItem(
                value: value,
                child: Text(value),
               );
           }).toList()),
         ),

1

【问题讨论】:

    标签: flutter dropdownbutton


    【解决方案1】:

    试试这个

    String dropdownValue = 'HEI';
    DropdownButton<String>(
            value: dropdownValue,
            icon: const Icon(Icons.arrow_downward),
            iconSize: 24,
            elevation: 16,
            style: const TextStyle(color: Colors.deepPurple),
            underline: Container(
              height: 2,
              color: Colors.deepPurpleAccent,
            ),
            onChanged: (String? newValue) {
              setState(() {
                dropdownValue = newValue!;
              });
            },
            items: <String>['HEI', 'ISEN', 'ISA', 'all']
                .map<DropdownMenuItem<String>>((String value) {
              return DropdownMenuItem<String>(
                value: value,
                child: Text(value),
              );
            }).toList(),
          ),
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-12
      • 2018-07-16
      • 1970-01-01
      • 1970-01-01
      • 2022-01-22
      • 2020-01-13
      • 2014-01-27
      • 1970-01-01
      相关资源
      最近更新 更多