Abdulkarim
Abdulkarim

Reputation: 587

problem with gridview.builder not scrolling

hi there am using gridview.builder and its not scrolling i got (A RenderFlex overflowed by 152 pixels on the bottom.) i tried to add physics: ScrollPhysics() its not work
my code

 body: Column(
    crossAxisAlignment: CrossAxisAlignment.center,
    children: [
      FutureBuilder(
          future: DBProvider.db.getPackageData("Package", value),
          builder: (BuildContext context, AsyncSnapshot snapshot) {
            if (snapshot.hasData) {
              final orientation = MediaQuery.of(context).orientation;
              return GridView.builder(
                   scrollDirection: Axis.vertical,
                   shrinkWrap: true ,
                    itemCount: snapshot.data.length,
                    gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                        crossAxisCount: (orientation == Orientation.portrait) ? 2 : 3),
                    itemBuilder: (BuildContext context, int index){
                    ItemModel item = snapshot.data[index];
                          return Card(
                            margin: EdgeInsets.all(5.0),
                            child: GridTile(
                              footer: Container(color: Colors.white,
                                  child: Text(item.name,
                                      textAlign: TextAlign.center)),
                              child: Container(child: Image.network(
                                  'https://cdn.vox-cdn.com/thumbor/fYRuzbQ2EvRavUEwWB_o9UdwhTk=/1400x788/filters:format(jpeg)/cdn.vox-cdn.com/uploads/chorus_asset/file/19157811/ply0947_fall_reviews_2019_tv_anime.jpg',
                                  fit: BoxFit.cover)),
                            ),
                          );
                  });

            } else {
              return Center(child: CircularProgressIndicator());
            }
          }),
    ],
  ),

Upvotes: 0

Views: 97

Answers (2)

Tanha Patel
Tanha Patel

Reputation: 453

Change Column to ListView and it would work great.

Upvotes: 0

Simon Sot
Simon Sot

Reputation: 3136

Wrap Column with SinglechildScrollView, for gridview.builder you need to set:

    physics: NeverScrollableScrollPhysics(),

Upvotes: 1

Related Questions