Reputation: 297
i am trying to find out why there is a big space or gab between those two flutter cards. i know there is something wrong here with the code. i checked out other posts on stackoverflow but nothing i have found could help me out, any help please. thanks
here is my code down below..
Container(
child: GridView.builder(
padding: EdgeInsets.zero,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
),
shrinkWrap: true,
physics: ScrollPhysics(),
itemCount: promoList.length,
itemBuilder: (BuildContext context, int index) =>
PromotionCard(promotion: promoList[index]),
),
)
@override
Widget build(BuildContext context) {
return Column(
children: [
Card(
margin: EdgeInsets.all(0.0),
elevation: 2.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8.0),
topRight: Radius.circular(8.0),
),
child: Image.asset(
promotion.imageUrl,
fit: BoxFit.cover,
width: MediaQuery.of(context).size.width,
),
),
Padding(
padding: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 20.0),
child: Text(
promotion.title,
style: TextStyle(
fontSize: 16.0,
fontFamily: 'BuffetRegular',
),
),
),
],
),
),
],
);
}
Upvotes: 0
Views: 268
Reputation: 699
try changing the child Aspect Ratio in your GridView =>
this ====>>>
childAspectRatio: (itemWidth / itemHeight),
to be like that for example
GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 1,
),
childAspectRatio: (100/ 100),
shrinkWrap: true,
//physics: ScrollPhysics(),
itemCount: promoList.length,
itemBuilder: (BuildContext context, int index) =>
PromotionCard(promotion: promoList[index]),
),
Upvotes: 1