How to add a ListView to a Column in Flutter?

后端 未结 13 1198
死守一世寂寞
死守一世寂寞 2020-11-30 22:53

I\'m trying to construct a simple login page for my Flutter app. I\'ve successfully built the TextFields and log in/Sign in buttons. I want to add a horizontal ListView.

13条回答
  •  没有蜡笔的小新
    2020-11-30 23:30

    You can check console output. It prints error:

    The following assertion was thrown during performResize(): Horizontal viewport was given unbounded height. Viewports expand in the cross axis to fill their container and constrain their children to match their extent in the cross axis. In this case, a horizontal viewport was given an unlimited amount of vertical space in which to expand.

    You need to add height constraint to your horizontal list. E.g. wrap in Container with height:

    Container(
      height: 44.0,
      child: ListView(
        scrollDirection: Axis.horizontal,
        children: [
          RaisedButton(
            onPressed: null,
            child: Text("Facebook"),
          ),
          Padding(padding: EdgeInsets.all(5.00)),
          RaisedButton(
            onPressed: null,
            child: Text("Google"),
          )
        ],
      ),
    )
    

提交回复
热议问题