I'm working on flutter web and I want my gridview scroll direction horizontal but when I added scrolldirection: Axix.horizontal it rotated the gridview. I know to make this easy I can use ListView but it takes too much code to make it responsive on the web. I just want the gridView itself to manage its crossAxisCount by screen width to become responsive. So I need help on how to make GridView scroll direction horizontal. Thanks
int gridCrossAxisCount;
if (size > 1600) {
gridCrossAxisCount = 4;
} else if (size > 1300) {
gridCrossAxisCount = 3;
} else if (size > 800) {
gridCrossAxisCount = 2;
} else {
gridCrossAxisCount = 1;
}
Container(
width: double.infinity,
height: 300,
child: GridView.count(
// scrollDirection: Axis.horizontal,
physics: ScrollPhysics(),
shrinkWrap: true,
primary: true,
padding: EdgeInsets.only(top: 15.0),
crossAxisCount: gridCrossAxisCount, //Screensize grid count
childAspectRatio: 0.60, //1.0
mainAxisSpacing: 0.2, //1.0
crossAxisSpacing: 4.0, //1.0
children: [
Container(
height: 200,
width: 200,
color: Colors.green,
),
Container(
height: 200,
width: 200,
color: Colors.red,
),
Container(
height: 200,
width: 200,
color: Colors.orange,
),
Container(
height: 200,
width: 200,
color: Colors.indigo,
),
],
),
),