flutter add widgets on top and bottom to a listview

后端 未结 4 1227
渐次进展
渐次进展 2021-02-05 23:37

Trying to add some widgets to before of a listview.... I searched and found to use expanded like:

  return Scaffold(
    appBar: AppBar(
      title: Text(\'Test         


        
4条回答
  •  醉酒成梦
    2021-02-06 00:17

    Try this.

    body : Container(
          constraints: BoxConstraints.expand(),
          padding: const EdgeInsets.all(10.0),
          child : ListView.builder(
             itemCount : providerApp.domains.length + 1,
             itemBuilder : (BuildContext context, int index){
                 Widget result;
                 if(index == 0){
                   result = Text("Header");
                 }else{
                   result = Container(..Your list item code here.);
                 }
                 return result;
             },
          ),
        )
    

    PS: If you want add widget to bottom of list, condition is provider.domain.length + 1.

    I hope to help you.

提交回复
热议问题