I have a gridview that I'd like to display in a non-specific height container. However, the gridview only shows up when I use container with a specified height. GridView goes invisible when I change Container to Expanded or Flexible.
Working Code:
return Container( //using container
height: 250, //with a specific height
child: GridView.count(
primary: false,
padding: const EdgeInsets.all(0.0),
crossAxisSpacing: 10.0,
crossAxisCount: 2,
children: <Widget>[
const Text('He\'d have you all unravel at the'),
const Text('Heed not the rabble'),
const Text('Sound of screams but the'),
const Text('Who scream'),
],
),
);
Non-working code:
return Expanded(
child: GridView.count(
primary: false,
padding: const EdgeInsets.all(0.0),
crossAxisSpacing: 10.0,
crossAxisCount: 2,
children: <Widget>[
const Text('He\'d have you all unravel at the'),
const Text('Heed not the rabble'),
const Text('Sound of screams but the'),
const Text('Who scream'),
],
),
);