A 有一个DropdownButtonFormField显示长文本的项目之一。长文本能够在下拉菜单中以多行显示。
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)
| 归档时间: |
|
| 查看次数: |
4905 次 |
| 最近记录: |