So far, into Flutter Fundamentals we’ve looked at the single child widget. At this point, you must be thinking, “Wow, Flutter is so easy! Everyone should be using it!” That is only partially true, because things are going to start getting a little more complicated. Let’s take a look at Multi child layout widgets. Multi child layout widgets are those who can have more than one widget as their children. One of the most basic widgets of them is Column.
What column does is create an array of its child and position them one after other in a vertical way. Hence the main axis for the column would be the Y-axis or the vertical axis. And the Cross axis would be the X-axis or the vertical axis.
If you don’t cap the main axis with help of other widget then main axis would be taken as infinity. And this might cause some problems. Because you might see a blank screen and don’t know what the problem is.
If you are thinking that I would just scroll around, here is a thing column by default isn’t scrollable. If you want to scroll it you will need to use some other widgets.
Properties:
Row is basically same as column but instead of placing its children vertically, Row would place its children horizontally. So main axis and cross axis are switched for row. It has all the same properties that a column has.
We have seen row and column till now, the easiest way to explain GridView is, row and column both are 1D (Dimension), while GridView is 2D array.
Instate of cross axis and main axis alignment grid view takes main axis and cross axis spacing. It would decide how much space will be left between its children.
We can implement GridView in various ways in Flutter:
GridView.count() is one which is used frequently and it is used when we already know the size of Grids. Whenever we have to implement GridView dynamically, we use GridView.builder(). Both are just like a normal array and dynamic array. In Flutter, the two GridView is mostly used.
GridView.count() is used with some named parameters. The properties that we can use are: crossAxisCount: It defines the number of columns in GridView.
The easiest way to define ListView is scrollable column. It is the most commonly used widget in the flutter app development.
There are 2 main ways to use or create ListView.
Table widget is used to display items in a table layout. There is no need to use Rows and Columns to create a table. If we have multiple rows with the same width of columns then Table widget is the right approach.
Properties:
Wrap works similar to a row or column based on mainAxis property given to this widget. But instead of showing error when they run out of space it will wrap the rest of the children widget into next row or column.
Properties:
So, this is what flutter provide us as multi child layout widgets. Happy coding!
Our team of experts will review your project and give you a quote at no cost.
In this episode of the The Lazy CEO Podcast,…
Join us for an enlightening episode of The CEO…
Creating multi-agent workflows is the future of AI development,…
How has sunflower lab's focus on integrating ai, data…
Businesses are quickly shifting towards optimized processes. And the…
Developers often make mistakes when using Power Automate, which…