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:
Related
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.
I am coding a website with Flutter. My layout uses "blocks" of vertical content laid within a SingleChildScrollView. They look like rectangles of content (with images, text, buttons, etc in them), taking up the whole screen horizontally, and the whole screen vertically.
Currently, whenever I move the screen size around (drag the web window to be different sizes) the website breaks. If I move it to be really small horizontally, I cannot fit in the content I need, if I move it to be small vertically I get overflow errors (and vice versa). This is because I am using MediaQuery.of(context).size.height/width to layout my website.
My rectangular blocks of "content" all have their same respective parent: Container(width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height) so they completely adjust everytime I move the window. Is there a better way to implement responsive web? Would it be better to just specify (for example) 620 pixels height for the Container and double.infinity for the width? And then somehow make everything fit inside not overflow/look weird? Also, when I drag the bottom of the web window nothing expands/grows properly because at that same time all my "content blocks" are all resizing their height because I am technically resizing the screen.
Finally, I've tried using BoxConstraints's minHeight, maxHeight, minWidth, and maxWidth, yet they don't seem to work and still produce the yellow/black overflow lines when testing in a webview. Huh?
Also, how would I get a bottom scrollbar to appear horizontally once my webview window is fully dragged close horizontally and half my content is cut off, but I still would like to see it. Would this be necessary? Or would another solution not need this? I'm not sure...
How are other people working around this and achieving this? I feel like I am doing this completely wrong. It shouldn't be this difficult.
(Also, using LayoutBuilder I have 2 additional builds for mobile/tablet when the screen width reaches less than 1100px)
I have a Vertical Layout Group with a Content Size Fitter, with children a TextMeshPro and a ScrollView.
(The TextMeshPro is not a problem, I only put it to show that I needed a Vertical Layout Group, so let's forget that)
Inside the ScrollView I have another Text element. This Text element expands both vertically and horizontally. I want the horizontality to be scrolled by the ScrollView and I want the ScrollView to adjust to the height.
So I want the ScrollView to be the same height as all of its internal elements. this is my goal. I don't want a scripted solution, I want to be able to do it directly from the hierarchy, where you define the layout of all elements.
However I am not able to do this, my idea was to put the Vertical Layout Group with a Content Size Fitter in the ScrollView, but if I do, I can no longer scroll the text horizontally, as it is constantly realigned based on the alignment defined in the Vertical Layout Group.
ps. At first you might think, but a text with a horizontal Content Size Fitter does not stretch vertically, what need is there to enlarge the ScrollView based on the height of the text? In reality I don't really use the Text component, I use a similar component created specifically for particular fonts, which also expand the text vertically, for this I need that the height of the ScrollView dynamically adapts to the child components, but I repeat, with a Vertical Layout Group, then I can't scroll anymore.
Solutions?
I had done well the layout system. Disable Pixel Perfect on Canvas fix the problem of the text realignment.
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.
I'm trying to create a flexible menu for my mobile project but i'm having trouble with new UI system. I could do this with code but i want to know if it's possible without coding.
Here is what i'm trying to do:
http://i.imgur.com/33yMRgV.jpg
Basically, i want to have a menu area with height of %10 of total screen height. So for example, if it's a HD device, i want height of the red area in the image to be 192 pixel (1920/10). I can do that easily but i also want to have 192x192 buttons aligned on top right corner. I can set the height to parent so it becomes 192 too but i can't set the width to height. I can use ratio fitter to make them squares but i can't place them side by side.
So basically i just want to set width of an element to it's height and puting them side by side without coding. Is it possible?
Thanks
Have a panel inside Canvas, and add horizontal layout group and then add your buttons inside this panel.
Note : You will need to increase the width of the panel more than the canvas in order to have buttons horizontally.