如何让DropdownButtonFormField支持多行文本?

use*_*856 8 dart flutter

A 有一个DropdownButtonFormField显示长文本的项目之一。长文本能够在下拉菜单中以多行显示。

落下

然而选择后,只显示 1 行文本。第二行变得隐藏。 已选择

String _selectedState = '';
List<String> _stateList = ['a very very long long long long long text'];

                DropdownButtonFormField<String>(
                  isExpanded: true,
                  value: _selectedState,
                  onChanged: (state) {
                   
                  },                     
                  items: _stateList
                      .map<DropdownMenuItem<String>>((String value) {
                    return DropdownMenuItem<String>(
                      value: value,
                      child: Text(value),
                    );
                  }).toList(),
                ),
Run Code Online (Sandbox Code Playgroud)

怎么解决这个问题呢?

Jha*_*kiz 12

添加overflow: TextOverflow.visible到您的代码如下:

 items: _stateList
        .map<DropdownMenuItem<String>>((String value) {
            return DropdownMenuItem<String>(
                value: value,
                child: Text(value,
                       overflow: TextOverflow.visible
                       ),
            );
  }).toList(),
Run Code Online (Sandbox Code Playgroud)