0

i want to fix my container size(width) according to the image which is getting from api(image.network..).So, how can i go for this?

i am trying to set dynamic width of container according to image which i get from image.network() in flutter.

  • have you tried this? `fit: BoxFit.cover` this command is making your image fit into your container height/width, but if you tried to set container width according of image. you will get overflow error in your console when the image was bigger than your screen size. – Stanly Nov 26 '22 at 10:08

1 Answers1

0

You will get overflow error in your device when the image was bigger than your device screen. I recommend you to use this

 Container(
          width: 100,
          height: 100,
          decoration: const BoxDecoration(
            image: DecorationImage(
              fit: BoxFit.cover,
              image: NetworkImage(
                  'image link'),
            ),
          ),
        ),