Flutter Grid View class

Mercy Jemosop
2 min readAug 25, 2021

Use grid view in your flutter application

Introduction

Grid View is a scrollable, 2D array of widgets. The main axis direction of a grid is the direction in which it scrolls (the scrollDirection).To create a linear array of children, use a ListView.

Grid View Constructors. Click on the link to for more properties of the constructors.

I have created 5 examples of gridview using different constructors to understand how it works. N.B read documentation to add more properties to the class. The constructor properties are not the same. All the widgets below will display like this(some may not have the appbar)

The example below uses the GridView constructor.Creates a scrollable, 2D array of widgets with a custom SliverGridDelegate.

The example below uses the GridView.count constructor.Creates a scrollable, 2D array of widgets with a fixed number of tiles in the cross axis.

The example below uses the GridView.builder constructor.Creates a scrollable, 2D array of widgets that are created on demand.

The example below uses the GridView.custom constructor.Creates a scrollable, 2D array of widgets with both a custom SliverGridDelegate and a custom SliverChildDelegate.

The example below uses the GridView.extent constructor. Creates a scrollable, 2D array of widgets with tiles that each have a maximum cross-axis extent

Bonus

Let’s create a simple project to retrieve my/your medium post in your flutter application. I will be using the extent constructor which resizes items to fit the screen.

Small screen

Large screen

Here is the code for that. You can do this with any list data.

This is a summary of GridView.extent

Happy coding!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

--

--

Mercy Jemosop

Software Developer. I am open to job referrals. connect with me on twitter @kipyegon_mercy