I am creating an app and I need a GridView in it. It didn't work with return GridView so I had to wrap it with a container. The problem is that if I don't define a precise height to the container, the code doesn't work. So I want the Container to perfectly match the size of the GridView whatever its height is. I tried to use the Wrap widget but didn't succeed. Can you help?
return Container(
//height: 10000, I want the height to adapt with the GridView
child: GridView.count(
scrollDirection: Axis.vertical,
crossAxisCount: 2,
children: List.generate(List.length, (index) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: Colors.black,
// image: [index].img,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.8),
spreadRadius: 2,
blurRadius: 2,
offset: Offset(0, 3), // changes position of shadow
),
],
),
),
);
})),
);