1

We have a grid view which is basically 3 columns with some additional in each of the columns but the last elements seem to be getting overflown

GridView.count(
                  crossAxisSpacing: 35,
                  shrinkWrap: true,
                  crossAxisCount: 3,
                  children: List.generate(3, (index) {
                    return Center(
                      child: Column(
                        children: [
                          const CircleAvatar(
                            minRadius: 30,
                          ),
                          const SizedBox(height: 20),
                          Text(
                            'Name',
                            style: Theme.of(context).textTheme.bodyMedium,
                          ),
                          const SizedBox(height: 10),
                          Text(
                            '$index',
                            style: Theme.of(context).textTheme.headline5,
                          ),
                        ],
                      ),
                    );
                  }),
                ),

enter image description here

Boss Nass
  • 3,384
  • 9
  • 48
  • 90
  • You need to increase the height of your widget. [like this link](https://stackoverflow.com/questions/48405123/how-to-set-custom-height-for-widget-in-gridview-in-flutter) – aminjafari-dev Oct 04 '22 at 09:38

3 Answers3

0

try to use .

   SizedBox(
height= // your option , 
child : // your Widegt,
)
0

Wrap the Column wih "SingleChildScrollView"

0
crossAxisSpacing: 35  This is the causing problem

Explanation:

Say if you have screen width of 300 and you have 3 columns of 80 width each.

This spacing would cause 80 + 35 + 80 + 35 + 80 = 310 which is 10px extra.

Solution:

Replace crossAxisSpacing by providing padding inside the grid items

Output after setting crossAxisSpacing = 0 :

enter image description here

krishnaacharyaa
  • 14,953
  • 4
  • 49
  • 88