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

前端 未结 12 594
情书的邮戳
情书的邮戳 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:53

    In my case with a future i did it like this:

    SingleChildScrollView(
          physics: ScrollPhysics(),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text("Hey ho let's go!"),
              
              Flexible(
                child: FutureBuilder(
                  future: getData(),
                  builder: (BuildContext context,
                      AsyncSnapshot> snapshot) {
                    
    
                    if (snapshot.connectionState != ConnectionState.done ||
                        snapshot.hasData == null) {
                      
                        return CircularProgressIndicator();
    
                    } else {
                      data = snapshot.data;
                      return ListView.builder(
                          physics: NeverScrollableScrollPhysics(),
                          shrinkWrap: true,
                          itemBuilder: (BuildContext context, int index) {
                            return dataItemWidget(size, data[index], context);
                          },
                          itemCount: data.length,
                        );
                    }
                  },
                ),
              ),
            ],
          ),
        ),
    

提交回复
热议问题