How to add a ListView to a Column in Flutter?

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

    As have been mentioned by others above,Wrap listview with Expanded is the solution.

    But when you deal with nested Columns you will also need to limit your ListView to a certain height (faced this problem a lot).

    If anyone have another solution please, mention in comment or add answer.

    Example

      SingleChildScrollView(
       child: Column(
         children: <Widget>[
           Image(image: ),//<< any widgets added
           SizedBox(),
           Column(
             children: <Widget>[
               Text('header'),  //<< any widgets added
                Expanded(child: 
                ListView.builder(
                  //here your code
                   scrollDirection: Axis.horizontal,
            itemCount: items.length,
            itemBuilder: (BuildContext context, int index) {
                return Container();
                       } 
             )
            ),
            Divider(),//<< any widgets added
             ],
           ),
    
         ],
       ), 
      );
    
    0 讨论(0)
提交回复
热议问题