flutterimagedartaspect-ratioexpanded

Flutter: keep the same ratio for all images in list in expanded widget


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


Solution

  • Finally, I just found a solution. Image.asset has a scale property. Change it to 2 or more did the job.