Flutter ListView.Builder() in scrollable Column with other widgets

前端 未结 12 596
情书的邮戳
情书的邮戳 2020-12-24 10:58

I have a TabBarView() with an amount of different views. I want of them to be a Column with a TextField at top and a ListView.Builder() below, but both widgets should be in

12条回答
  •  南方客
    南方客 (楼主)
    2020-12-24 11:39

    Placing the ListView inside an Expanded widget should solve your problem:

    @override
    Widget build(BuildContext context) {
    return new Column(
      mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.max,
        children: [
          new Padding(
              padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
              child: new TextField(
                decoration: new InputDecoration(
                    hintText: "Type in here!"
                ),
              )
          ),
          new Expanded(child: ListView.builder(
              itemCount: _posts.length, itemBuilder: _postBuilder))
        ],
       );
    }
    

提交回复
热议问题