Adjust GridView child height according to the dynamic content in flutter

前端 未结 5 2233
执念已碎
执念已碎 2020-12-23 17:14

How to implement this complex view in the flutter?

I am trying to implement a GridView with n columns and the child should be of a certa

5条回答
  •  忘掉有多难
    2020-12-23 17:52

    Edit: I added the constructor StaggeredTile.fit in the 0.2.0. With that you should be able to build you app ;-).

    First comment: For now with StaggeredGridView, the layout and the children rendering are completely independant. So as @rmtmckenzie said, you will have to get the image size to create your tiles. Then you can use StaggeredTile.count constructor with a double value for the mainAxisCellCount parameter: new StaggeredTile.count(x, x*h/w) (where h is the height of your image and w its width. So that the tile with have the same aspect ratio as your image.

    What you want to accomplish will need more work because you want to have an area below the image with some information. For that I think you will have to compute the real width of your tile before creating it and use the StaggeredTile.extent constructor.

    I understand this is not ideal and I'm currently working on a new way to create the layout. I hope it will help to build scenarios like yours.

提交回复
热议问题