I am creating food app ui, i created card of buttons with images, now i have a problem with size of images in my buttons, they all have same height, width, padding and image size but different text wrap so they return different image scale. I already tried to make it on desired size, didn’t help
class PopularCards extends StatelessWidget {
PopularCards({
super.key,
// required this.image,
required this.name,
required this.image,
});
// Image image;
String name;
String image;
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(vertical: 10),
child: Container(
width: 110,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
offset: Offset(0, 3),
)
]),
child: Column(
children: [
Expanded(
child: ConstrainedBox(
constraints: BoxConstraints.expand(),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
minimumSize: Size.fromHeight(40),
backgroundColor: Colors.white
),
onPressed: () {
print('Hey');
},
child: Image.asset(image)),
)
),
Text(name, style: TextStyle(fontSize: 14)),
],
),
),
);
}
}
3
Answers
Try this code, wrap the image in a container and give the container height and width.
Try to give the Container height and width with:
create a custom button with onTap function and image child
then call the custom button in a row
code for custom button
the showing page is