I have a list with an Image and Text in a Row. Both are in an Expanded
widget to get the same width.
Widget item(String value, String imageLocation) => Row(children: [
Expanded(
child: Image.asset(
'assets/images/$imageLocation.png',
)),
Expanded(
child: Text(
value,
textAlign: TextAlign.center,
style: const TextStyle(
color: Colors.black54,
),
),
),
]);
That, everything is well drawn, but the images are too big. Initially, all images have not the same size. And when I want to reduce it on screen by putting them in a Container with a definite size, many images are well reduced, but not the smallest which appear always big. I also tried different fit properties, but without any success.
What I want is to reduce all images with the same ratio, so that they keep the same aspect as currently but smaller.
How can I do that? Thanks
CodePudding user response:
There is an AspectRatio
widget in Flutter, you can wrap your image widget with it.
CodePudding user response:
You can wrap your Image
with the AspectRatio
widget like this:
AspectRatio(
aspectRatio: 16/9,
child: Image.asset(
'assets/images/$imageLocation.png',
)),
CodePudding user response:
Finally, I just found a solution. Image.asset
has a scale
property. Change it to 2 or more did the job.