Flutter 如何在一列中放置两个ListView?

Flutter 如何在一列中放置两个ListView?,flutter,Flutter,我有两个带有扩展文件的ListView,我希望将它们一个接一个地放在一个列中,该列中首先有一些其他小部件。 这是我的密码 @override Widget build(BuildContext context) { // TODO: implement build return new Scaffold( appBar: new AppBar( title: new Text("Project Details"), backgroundColor: C

我有两个带有扩展文件的ListView,我希望将它们一个接一个地放在一个列中,该列中首先有一些其他小部件。 这是我的密码

 @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())


    ]
        ,
      )
      ,
    )
);
@覆盖
小部件构建(构建上下文){
//TODO:实现构建
归还新脚手架(
appBar:新的appBar(
标题:新文本(“项目详情”),
背景颜色:颜色。蓝色[800]),
正文:
新填充物(填充物:新边集。全部(10.0),
子项:新列(子项:[
新文本(project.name,样式:new TextStyle(
fontWeight:fontWeight.bold,
颜色:颜色。蓝色[700],
字体大小:15.0
)),
新赛艇手(“地区”,项目区),
新赛艇手(“河流”,项目河流),
新赛艇手(“交咨会批准”,项目。交咨会批准),
新赛艇手(“Func批准”,项目资金批准),
新行(儿童:[
新扁平按钮(按下时:空,
颜色:颜色,蓝色,
儿童:新文本(“图库”),
text颜色:颜色。白色,),
新扁平按钮(按下时:空,
颜色:颜色,蓝色,
子项:新文本(“上载图像”),
text颜色:颜色。白色),
新扁平按钮(
onPressed:null,
颜色:颜色,蓝色,
子项:新文本(“更新”),
text颜色:颜色。白色),
],),
新建ListView(子项:getSfListTiles()),
新建ListView(子项:getWorkStatementTiles())
]
,
)
,
)
);
}


使用这个,小部件的主体显示为空。如果我直接将ListView设置为主体,它们显示得很好。我错过什么了吗

尝试将您的
列表视图包装到
展开的
中。它没有固有的高度,所以你需要给它一个。

列表视图
包装在一个固定大小的
容器中
对我很有用

您需要提供受约束的高度,以便能够将
列表视图
放入
中。有很多方法可以做到这一点,我在这里列出了一些

  • 对两个列表都使用
    展开的

    Column(
      children: <Widget>[
        Expanded(child: _list1()),
        Expanded(child: _list2()),
      ],
    )
    
  • 对这两个选项都使用
    SizedBox

    Column(
      children: <Widget>[
        SizedBox(height: 200, child: _list1()),
        SizedBox(height: 200, child: _list2()),
      ],
    )
    
  • 如果
    列表视图
    足够短,可以放入
    ,请使用

    ListView(shrinkWrap: true)
    

  • 我怎样才能把整个身体包装在一个滚动视图中呢?你可能应该把它作为一个单独的问题来问;这取决于你有多少内容。如果它很多,请考虑一个CuffScLoVIEW,如果不是很大的话,StutelPosiScLoVIEW和ListVIEW到Cyrn。使用CudioScLoVIEW或SunLoeStudiVIEW视图为子控件提供了一个黑色的大背景文本。我正在寻找的解决方案是两个ListVIEW(包含扩展瓦片)。在不展开时只占用所需空间,但展开时应将其拉伸到最大高度,我在这里遇到的问题是,展开后的两个ListView会平均占用整个空间,展开后,它们会在此区域内展开。使用CustomScrollView的解决方案,
    Column(
      children: <Widget>[
        Flexible(child: _list1()),
        Flexible(child: _list2()),
      ],
    )
    
    ListView(shrinkWrap: true)