GridView in Flutter - Learn About GridView In Depth
When we need widgets stacked like in a grid, we use GridView. There are two main ways in which you can use a GridView.
First Method, Using GridView.count()
GridView.count requires 2 things, the first is cross axis count which tells how many boxes or grids will be there in one row.
The second is children property which takes in a list of widget.
Second Method, Using GridView.builder()
GridView.builder() takes in various parameters, one is itemCount which takes in number of items we want to display. Other required property is gridDelegate controls the layout of the tiles in gridView and the last property which we will talk about is itemBuilder which is similar to the one used in List View. itemBuilder takes in a function with two parameters, context and index. context tells where to place the child on screen or basically which context to place the child in and index is a number which runs through 0 to itemCount - 1.
If You want to use SliverGridDelegateWithMaxCrossAxisExtent()
Output for the 1st method:
Output for Method 2 (MAX CROSS AXIS):
Output for Method 2 Max Cross Extent:
To know more about Text Widget : Text Widget In Depth - Flutter.
Read about Algorithms at www.introtoalgo.com