Jov*_*ski 9 flutter flutter-layout
将DropdownButton
在颤振基础上设置最大的宽度DropdownMenuItem
从它的项目。如果选择了一个小项目,这会在项目和箭头之间留下大量空白。如何使按钮缩放以适合所选项目的宽度?
我尝试使用Expanded
, 一些Flexible
东西,但我仍然无法改变它的宽度。
DropdownButton(
value: null,
hint: Text("Small text"),
items: ..., //Text widgets that have more text and are larger than the hint
)
Run Code Online (Sandbox Code Playgroud)
这有效:
new Container(
padding: const EdgeInsets.fromLTRB(10.0, 5, 10, 0),
child: new Container(
padding: const EdgeInsets.fromLTRB(10, 5, 5, 5),
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(5.0),
bottomLeft: const Radius.circular(5.0),
bottomRight: const Radius.circular(5.0),
topRight: const Radius.circular(5.0))),
child: new Center(
child: new Column(children: [
new DropdownButton(
underline: Text(''),
icon: Icon(Icons.keyboard_arrow_down),
hint: new Text('Small text'),
style: TextStyle(
color: Colors.white30,
),
isExpanded: true,
value: _selectedLocation,
onChanged: (String newValue) {
setState(() {
_selectedLocation = newValue;
});
},
items: _locations.map((String location) {
return new DropdownMenuItem<String>(
value: location,
child: new Text(
location,
style: TextStyle(
color: myColour, fontWeight: FontWeight.bold),
),
);
}).toList(),
),
])),
))
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5655 次 |
最近记录: |