Flutter Auto Resizing Grid Cards based on Screen Size

Solution 1:

I hope this will do the job.

int count;

if (MediaQuery.of(context).orientation == Orientation.landscape)
  count = 4;

else
  count = 2;


return new GridView.count(
  primary: false,
  padding: const EdgeInsets.all(1.5),
  crossAxisCount: count,
  childAspectRatio: 0.80,
  mainAxisSpacing: 1.0,
  crossAxisSpacing: 1.0,
  children: _loadCategories(), //new Cards()
  shrinkWrap: true,
);

and then do the rest.

Solution 2:

use a width of the screen to know how many rows must set in your Grid

double width=MediaQuery.of(context).size.width;
int widthCard= (YOUR WIDTH FOR ONE COLOM);    

int countRow=width~/widthCard;

** Note: width will be the height of the screen(window) in landscape mode so also this code will be work fine in landscape orientation