Reputation: 205
my code is inside a ListView Widget. i am having a problem with my images, since each one of them have a dimensions which is different than the other ones. i want them to appear all with the same dimension, but some of them is being bigger than the others.
note : i have used Width and Height and it didn't help
i want both of them to be with the same dimension but the second one is bigger ! i have even tried the BoxFit method as well and didn't help. here is my code sample:
ListView(
children: List.generate(
sandwichFood.length,
(index) => Padding(
padding: EdgeInsets.all(10),
child: Container(
padding: EdgeInsets.only(left: 10),
decoration: _foodDecor(),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
Text(
sandwichFood[index],
style: TextStyle(fontSize: 25),
textAlign: TextAlign.left,
),
Text(
'Price : ${sandwichPrice[index]}',
style: TextStyle(fontSize: 20),
),
],
),
Image(
image: AssetImage(sandwichImage[index]),
height: 200,
width: 200,
),
],
),
),
),
),
);
Upvotes: 0
Views: 2336
Reputation: 3757
Image
class has parameter fit
. Try to use it:
Image(
image: AssetImage(sandwichImage[index]),
fit: BoxFit.cover,
height: 200,
width: 200,
)
Upvotes: 2