SizedBox(
height: 50,
child: GridView.builder(
shrinkWrap: false,
itemCount: 4,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4, childAspectRatio: 1),
itemBuilder: (context, index) {
return Container(height: 25, width: 25);
},
),
)
Despite setting an explicit height of 25 on the Container children when the Containers are rendered they’re given a height of 83? And I can’t stop the containers from overflowing the GridView which has an explicit height of 50?
2
Answers
I think the
SizedBox
size is ignored by its parent because of missing alignment value. Try wrapping it inAlign
widget or any widget that can align it child/children:Row
,Column
,Container
withAlignment
property,…You can set
mainAxisExtent
property forSliverGridDelegateWithFixedCrossAxisCount
or use