How can I make an image fit into available space when too wide?

androidneil

I have an image asset which is 1250px wide. I want it to fill the given space, but because the image is too large I always get an overflow error. I have tried specifying a width for the image, but of course this is device dependent so is not a solution. How can I make this fit into the given space?

Widget build(BuildContext context) {
    return Stack(
      children: [
        Column(
          children: <Widget>[
            Padding(
              padding: EdgeInsets.only(
                  left: 12.0, top: 5.0, bottom: 16.0, right: 0.0),
              child: Row(
                children: [
                  Image.asset(
                    'assets/images/my_image.png',
                    fit: BoxFit.fitWidth,
                    width: 348, // works on one device but not others
                  ),
                ],
              ),
            ),
          ],
        ),
      ],
    );
  }
Jahidul Islam

You can try with phone-specific dynamic width

Image.asset(
  'assets/images/my_image.png',
  fit: BoxFit.fitWidth,
  width: MediaQuery.of(context).size.width-12,                 
),

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

LaTeX table too wide, how can I make it fit?

How can I make HTML table footer take available space on each page when printing on multiple pages?

How to make an input field only as wide as there is space available?

How can I make my textfield fill the available vertical space?

How can I make my image fit in completely in a UIView

How to make several Components resize vertically to fit in the available space in CodenameOne?

How to make subview fit all available vertical space in HStack?

Css make an image fit in a 100% wide div

How do I horizontally and vertically center an image on the page, except for when it's too big to fit?

Make edit text fit available space Android

How can i make pageView.Builder occupy all available space in flutter?

How do I make a button take up all available space when its parent has a min height?

How to make a rotated image fill available space in Flutter?

How can I fit an image to a rectangle in visio?

How can I resize the image to fit the picturebox?

how i can fit text to an image with css

How do I fit an image inside of this specified grid space?

How can I determine the available amount of disk space when using a charm?

How to make LinearLayout fill available space when some elements are not set

How can I make all inserted images in the textarea 100% wide

How can I make an element as wide as it is high in css?

How can I make all elements equally wide in flexbox?

How to make the div wide enough when I scroll the screen?

How can I make the background-image of a tabpage spread out to the available size?

In Flutter, how can I make a scrollable view of multiline text take up all the available horizontal space, as part of a column?

In a .bat file, how can I test available disk space?

How can I use all space available in a Grid?

How can I create a scrollable list that takes all available space?

How can I make shell aliases available when shelling out from Vim?

TOP Ranking

HotTag

Archive