Container inside Row and Row inside Container - flutter

In a flutter app, what is the difference between a Container inside a Row and a Row inside Container?
In flutter in each time I want to make an app, I took minutes to ask my self
which one should I choose?

In flutter Row and Column provide a way to use the Flex layout system aka FlexBox.
In short Flex is a one-dimensional layout system, where in the children can be aligned on the main-axis or cross-axis, the main axis can be defined as horizontal or vertical.
A Container in Flutter is a general-purpose widget that gives you access to a range of properties like padding, decoration, size etc. A full-list is available at the API Docs
To answer your question,
A Container in a Row is like we said above, a child of a Flex, which means it will respect the properties of alignment set by the parent (MainAxisAlignment/CrossAxisAlignment )
A Row in a Container, is the opposite of that which means that, the Row or Column will respect properties set on the Container that is for example the Decoration or Size properties amongst others.

Related

trouble with fixing elements in row in flutter

look at the pic
I don't want elements to change their positions especially in horizontal axis when their strings changed
I mean it should be like a table with fixed columns.
can I do this just with row?
It's probably because you set a defined width for spacing.
You could use a combination of Flexible & Expanded widgets to wrap all the children in your Row.
That should align them correctly.
You can find the corresponding code here

Flutter: Is there any difference between these layouts?

In flutter, Is there any difference between these layouts? -
Expanded
SizedBox.expand
BoxConstraints.expand()
If all are same, why there are multiple layout classes/functions for same functionality?
As far as I know.
Expanded widget can only used inside of Row, Column and Flex. It helps to expand the children based on the flex value. By default - it's 1.
SizedBox.expand - It will expand the child as large as it's parent allows. You can put anywhere unlike Expanded.
BoxConstraints.expand - Usually takes as object of ConstrainedBox constraints property.
From the documentation -
Creates box constraints that expand to fill another box constraints.
If width or height is given, the constraints will require exactly the
given value in the given dimension.

GridView with fixed size children

I need a grid that contains children of fixed sizes.
GridView expands its children, which is not what I need. The grid should simply size itself according to it's children by setting the crossAxisCount.
My current solution is to use simple columns and rows, but that's so much boilerplate code for just a common widget.
You will have to do it dynamically, and supply the value of the crossAxisCount dynamically

What are the default heights of CupertinoTabBar and CupertinoSliverNavigationBar?

i'm trying to set widgets sizes according to screen height. For example i have 3 widgets inside my body, the first and second one should be 20% from whole screen size, the third one - the rest.
The problem is that i have CupertinoSliverNavigatoinBar and CupertinoTabBar, so i can't calculate height of my third widget.
I'm trying to implement this thing.
According to documentation, CupertinoTabBar height is 50.0. To verify this you can check the source code of CupertinoTabBar and there is constant which called _kTabBarHeight.
But for your particular problem I think you should use Expanded widget with flex property.

How can I enforce vertical alignment of GTK widgets across containers?

I'm using PyGTK on Windows to develop a small application.
How can I enforce vertical alignment of widgets across containers to achieve something like this?
In the mockup, widgets are in separate frames, but I want to maintain vertical alignment as if they were in the same gtk.Table. If I put them in the same table then I can't put a gtk.Frame around the groups of widgets.
Maybe it's already too late for you, but for other people that find this question. You can create an array of SizeGroup with 8 elements, and add to each element every widget that should go on the same column, this will make the width of each cell on the respective grid to be the same size, if all widgets are added, this will have the side effect of also align them vertically. Just be sure the amount of columns in the grid below is the same as above.
Also, if your labels need some special alignment there is currently a bug that does not let you use halign and valign when using SizeGroup, see https://bugzilla.gnome.org/show_bug.cgi?id=733981 .