RefreshIndicator not working with GridView as GridView requires physics:ScrollPhyscis()&refreshindicator requires AlwaysScrollablePhysics() to appear

Viewed 45

RefreshIndicator not working with GridView as GridView requires physics:ScrollPhyscis()&refreshindicator requires AlwaysScrollablePhysics() to appear

GetBuilder<StateController>(builder: (value) {
                        return RefreshIndicator(
                          onRefresh: refresh,
                          child: GridView.builder(
                              physics: ScrollPhysics(),
                              itemCount:
                                  _offerCashbackCont.mdlOffers.data.length,
                              shrinkWrap: true,
                              padding: EdgeInsets.all(10),
                              gridDelegate:
                                  SliverGridDelegateWithFixedCrossAxisCount(
                                      crossAxisCount: 2,
                                      mainAxisSpacing: 10.0,
                                      crossAxisSpacing: 10.0,
                                      childAspectRatio: 0.7),
                              itemBuilder: (context, index) {
                                return SingleProduct(
                                  imageUrl: _offerCashbackCont
                                      .mdlOffers.data[index].image,
                                  title: _offerCashbackCont
                                      .mdlOffers.data[index].title,
                                  status: _offerCashbackCont
                                      .mdlOffers.data[index].status,
                                  model:
                                      _offerCashbackCont.mdlOffers.data[index],
                                  isLike: _offerCashbackCont
                                      .mdlOffers.data[index].isLike,
1 Answers

It should be enough to put the GridView inside a SingleChildScrollView a set GridView physics to NeverScrollable

return RefreshIndicator(
  onRefresh: refresh,
  child: SingleChildScrollView(
    child: GridView.builder(
      physics: const NeverScrollableScrollPhysics(),
      itemCount:
          _offerCashbackCont.mdlOffers.data.length,
      shrinkWrap: true,
      padding: EdgeInsets.all(10),
      gridDelegate:
          SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 2,
              mainAxisSpacing: 10.0,
              crossAxisSpacing: 10.0,
              childAspectRatio: 0.7),
      itemBuilder: (context, index) {
        return SingleProduct(...
Related