Listview 垂直视口的宽度是无限的

Listview 垂直视口的宽度是无限的,listview,flutter,Listview,Flutter,我是一个新手,很明显,我被一些琐碎的事情缠住了 下面是一个有状态类: class Menu extends StatefulWidget { Menu({Key key}) : super(key: key); @override MenuState createState() => MenuState(); } class MenuState extends State<Menu> { @override Widget build(BuildContex

我是一个新手,很明显,我被一些琐碎的事情缠住了

下面是一个有状态类:

class Menu extends StatefulWidget {
  Menu({Key key}) : super(key: key);
  @override
  MenuState createState() => MenuState();
}

class MenuState extends State<Menu> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Container(
      child: new Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          new Padding(padding: EdgeInsets.fromLTRB(0.0, 50.0, 0.0, 0.0)),
          new FetchSummary(context: context),
        ],
      ),
    );
  }
}
最后更新 我从以下位置替换了呼叫代码:

return new Container(
  child: new Row(
    children: <Widget>[
      new Padding(padding: EdgeInsets.fromLTRB(0.0, 50.0, 0.0, 0.0)),
      new FetchSummary(context: context),
    ],
  ),
);
它成功了。我想它不喜欢Row小部件。

试试这个

return  ListView.builder(
                      //scrollDirection: Axis.vertical,
                      //shrinkWrap: true,
                      itemCount: myData.length,
                      padding: const EdgeInsets.only(bottom: 50),
                      itemBuilder: (BuildContext context, int index) {
                        return Container(
                            //margin: const EdgeInsets.symmetric(vertical: 1),
                            color: Color.fromRGBO(107, 164, 147, 0.5),
                            child: ListTile(
                              title: new Text(
                                "Dummy Text",
                              ),
                            ));
                      });

要在Row小部件中运行它,您可能需要为容器提供一定的宽度以适应它

像这样:

return new Container(
 width: 50,
 child: new Row(
   children: <Widget>[
     new Padding(padding: EdgeInsets.fromLTRB(0.0, 50.0, 0.0, 0.0)),
     new FetchSummary(context: context),
   ],
 ),
);
返回新容器(
宽度:50,
孩子:新的一排(
儿童:[
新填充(填充:EdgeInsets.fromLTRB(0.0,50.0,0.0,0.0)),
新建FetchSummary(上下文:上下文),
],
),
);

尝试删除柔性包装和柱形包装
收缩包装:true,
不起作用。我把它放在帖子里只是想告诉大家我已经试过这些东西了。我想我可以不住在外行。如果需要,我会测试一下。
return new Container(
  child: new Row(
    children: <Widget>[
      new Padding(padding: EdgeInsets.fromLTRB(0.0, 50.0, 0.0, 0.0)),
      new FetchSummary(context: context),
    ],
  ),
);
return new Container(
  child:
      new FetchSummary(context: context),
  );
return  ListView.builder(
                      //scrollDirection: Axis.vertical,
                      //shrinkWrap: true,
                      itemCount: myData.length,
                      padding: const EdgeInsets.only(bottom: 50),
                      itemBuilder: (BuildContext context, int index) {
                        return Container(
                            //margin: const EdgeInsets.symmetric(vertical: 1),
                            color: Color.fromRGBO(107, 164, 147, 0.5),
                            child: ListTile(
                              title: new Text(
                                "Dummy Text",
                              ),
                            ));
                      });
return new Container(
 width: 50,
 child: new Row(
   children: <Widget>[
     new Padding(padding: EdgeInsets.fromLTRB(0.0, 50.0, 0.0, 0.0)),
     new FetchSummary(context: context),
   ],
 ),
);