How to add a ListView to a Column in Flutter?

后端 未结 13 1115
死守一世寂寞
死守一世寂寞 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:26

    Expanded Widget increases it’s size as much as it can with the space available Since ListView essentially has an infinite height it will cause an error.

     Column(
      children: [
        Flexible(
          child: ListView(...),
        )
      ],
    )
    

    Here we should use Flexible widget as it will only take the space it required as Expanded take full screen even if there are not enough widgets to render on full screen.

提交回复
热议问题