How do you create a dynamic self-sizing card in a 2 column Grid with infinite scrolling in Flutter? I need each card to contain a photo and some labels. I want the cards to dynamically size based on how tall the content of the data is. The images would fill the width of the card and keep the widths consistent and dynamically adjust the height in proportion to the width. The photos could have different widths and sizes, and I would like them to display the full image and have the image not cut off. The labels should dynamically go to the following line if they contain too much text. Could someone please tell me if something like that is possible in Flutter and how to do it? Thanks.
Related
I am new to Flutter and trying to convert my iOS app to Flutter. However, I am having difficulty laying out the screen. Below is what the iOS screen looks like. I keep on getting red screens with layout errors saying it cannot layout the screen. When I add a column and add to that an image and a horizontally scrolling grid in Flutter I get the layout errors. How can I layout this screen?
I think it should have a column as the main widget. Then, a large image should be displayed, which displays centered width-wise on the screen. It should be constrained height-wise and wide enough not to distort the image. The photos come in a variety of heights and widths.
Then there should be a large text field centered width-wise in the central column. Then a breed text box is centered width-wise in the central column and followed by a line of stats—lastly, a city, state, and miles.
Then a centered list of icons with a single line of text-centered underneath each icon. Finally, the whole icon bar should be centered width-wise in the column.
Next, there should be a line of small photos of the cat, which is left aligned to the column and fills to the right going off-screen and scrollable horizontally. It should be a grid with a staggered layout width-wise. Each image should be a fixed height and a ratio of width to fixed height to fit the image without distorting it. The images should have rounded corners. The width and height of the source image are known ahead of time and need to be adjusted to fit the new fixed height.
Lastly, there should be a web browser that fills the width of the column with a height large enough to hold the content of the HTML without scrolling the web browser so the whole screen looks like it is one screen.
The whole screen should be able to scroll vertically but not horizontally to see the main column's total content.
Below is what the screen should look like:
I'm having a difficult problem in the newfeeds of app.
Users post multiple images of different sizes, and what we want is to be displayed in the same fashion as on the facebook app.
I'm really one keyword or idea to do this.
Thanks!
This is UI about what I want
If you want show widget same your image, I think you can try this package: https://pub.dev/packages/flutter_staggered_grid_view
Features
Configurable cross-axis count or max cross-axis extent like the GridView
Tiles can have a fixed main-axis extent, or a multiple of the cell's length.
Configurable main-axis and cross-axis margins between tiles.
SliverStaggeredGrid for using in a CustomScrollView.
Staggered and Spannable grid layouts.
I'm trying to display images in a fixed size box (the grey area in the image here). When the submit button is pressed new images will be fetched from the internet. But the images will be different sizes.
So to prevent the "submit" button moving up and down due to different size images (and potentially having it off the screen) I'd like the images to fit inside the box. (I suppose there are a few options there, for example having the image resize to fit in the box or having the image be clipped and still fitting in the box.) I've been messing with containers and columns etc for ages but nothing seems to work.
what is the best way to fit images of different sizes into a fixed size box ?
The Image widget can have a height be specified. You can read more about that here
I want to implement scrollview in Unity3D 5 UI with horizontal images downloaded from web, they have different random aspect ratios, but I want them to be constant height. And width to be according their aspect ratio, like this:
I tried to use Horizontal Layout Group, but images get too little, so it can all fit in group, when I want them to be constant height and stretch parent's width. So, like, parent's widht is primary and it affects children, but I want children to affect total parent's width (expand it when adding new children images).
Any ideas how to achieve this? Thanks.
You need to use ScrollView with horizontal scrolling enabled and vertical scrolling disabled. Setup your hierarchy as in the image below:
On the GameObject named Content attach Horizontal Layout Group and Content Size Fitter with the following settings:
Then on all your images attach a Layout Element component and during runtime calculate the width using the aspect ratio of the image and height to the Content gameobject and assign this width to Preferred Width property of Layout Element Component: In the following image 300 is the calculated width for the image:
As a result any images you add as child to the Content gameobject will increase their parent's width and also you will be able to scroll horizontally to view all the image.
p.s. I wrote this answer in a hurry. Hopefully it will make sense to you if not let me know and I will improve my answer.
I was just experimenting with UIStackView. In this quiz app i have different sized imaged, so i want the image to fill the space between the top button and the question text at the top. The buttons have constraints on them so they should be any size under 50px. As of now the top button is the one getting auto increased size, but that seems kinda random.
According to what I understand you have all the items inside a vertical UIstack. The images have different sizes so the available space for the buttons will changes based on the size of the image. I suggest that you add constraints to all buttons to be equal in height. This way they will re-size based on the available space but they will all have the same height.