I would like to implement in Flutter a Staggered Grid view - such as the Pinterest staggered grid view (which used to be implemented via their own Android Widget, and now via the Google's StaggeredGridLayoutManager).
So the requirements are:
I know there is a plugin which is named flutter_staggered_grid_view, but this is of no use because it requires to know in advance the precise height of each tile of the grid - which of course it is not my case.
The simplest way to get started using grids is by using the GridView. count() constructor, because it allows you to specify how many rows or columns you'd like. To visualize how GridView works, generate a list of 100 widgets that display their index in the list.
Creating GridView In Flutter We can create a grid view in flutter by calling the constructor of GridView class and providing it with required properties. It has one required property which is gridDelegate. It controls the layout of the child widgets of the grid view.
I've updated the flutter_staggered_grid_view package.
Now you can add tiles that fit their content size like this:
You have to create tiles using the StaggeredTile.fit(this.crossAxisCellCount)
constructor to do it.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With