skip to Main Content

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

3

Answers


  1. Chosen as BEST ANSWER

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


  2. There is an AspectRatio widget in Flutter, you can wrap your image widget with it.

    Login or Signup to reply.
  3. You can wrap your Image with the AspectRatio widget like this:

     AspectRatio(
       aspectRatio: 16/9,
        child: Image.asset(
      'assets/images/$imageLocation.png',
    )),
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search