我有两个带有ExpansionTiles的ListView,我希望一个接一个地放在一个列中,其中首先包含一些其他Widgets.这是我的代码,
@override
Widget build(BuildContext context) {
// TODO: implement build
return new Scaffold(
appBar: new AppBar(
title: new Text("Project Details"),
backgroundColor: Colors.blue[800]),
body:
new Padding(padding: new EdgeInsets.all(10.0),
child: new Column(children: <Widget>[
new Text(project.name, style: new TextStyle(
fontWeight: FontWeight.bold,
color: Colors.blue[700],
fontSize: 15.0
)),
new RowMaker("District", project.district),
new RowMaker("River", project.river),
new RowMaker("Tac Approved", project.tacApproved),
new RowMaker("Func Sanctioned", project.fundSanctioned),
new Row(children: <Widget>[
new FlatButton(onPressed: null,
color: Colors.blue,
child: new Text("Gallery"),
textColor: Colors.white,),
new FlatButton(onPressed: null,
color: Colors.blue,
child: new Text("Upload Images"),
textColor: Colors.white),
new FlatButton(
onPressed: null,
color: Colors.blue,
child: new Text("Update"),
textColor: Colors.white),
],),
new ListView(children: getSfListTiles()),
new ListView(children: getWorkStatementTiles())
]
,
)
,
)
);
Run Code Online (Sandbox Code Playgroud)
}
使用它,小部件主体显示空白.如果我将ListView直接设置为正文,它们会显示正常.我错过了什么吗?
Cop*_*oad 15
您需要提供约束高度能够把ListView
里面Column
。有很多方法可以做到这一点,我在这里列出了一些。
使用Expanded
两个列表
Column(
children: <Widget>[
Expanded(child: _list1()),
Expanded(child: _list2()),
],
)
Run Code Online (Sandbox Code Playgroud)给一个Expanded
和另一个SizedBox
Column(
children: <Widget>[
Expanded(child: _list1()),
SizedBox(height: 200, child: _list2()),
],
)
Run Code Online (Sandbox Code Playgroud)使用SizedBox
对他们俩的。
Column(
children: <Widget>[
SizedBox(height: 200, child: _list1()),
SizedBox(height: 200, child: _list2()),
],
)
Run Code Online (Sandbox Code Playgroud)使用Flexible
,您可以更改其中的flex
属性,就像Expanded
Column(
children: <Widget>[
Flexible(child: _list1()),
Flexible(child: _list2()),
],
)
Run Code Online (Sandbox Code Playgroud)如果您ListView
足够矮,可以适应Column
,请使用
ListView(shrinkWrap: true)
Run Code Online (Sandbox Code Playgroud) 归档时间: |
|
查看次数: |
8890 次 |
最近记录: |