How to set rectangular shape to children of a grid?
150
GridView.count(
crossAxisCount: 2,
childAspectRatio: 0.8, // change this value for different results
crossAxisSpacing: 5,
mainAxisSpacing: 5,
padding: EdgeInsets.all(10.0),
children: []
)
Author by
William Pineda MHA
Updated on January 05, 2023Comments
-
William Pineda MHA over 1 year
I need to make the following page in flutter:
I need to make the following page in flutter. I already tried to do it with a SliverGrid.count(), the problem is that it is the grid that is in charge of establishing the width and height of its children. In addition, the width and height established are always the same(square shaped). Somehow I need to be able to modify the width and height and make it rectangular) so that the children are very similar to how they can be seen in the image
I appreciate any help you can give me
-
Kaushik Chandru almost 2 yearsIn image all children are of same size.
-
William Pineda MHA almost 2 yearsActually what I'm looking for is that the children are rectangular and not square. However, when I tried to set a height greater than the width. Flutter did not take it and all the children continued to look square
-
Yeasin Sheikh almost 2 yearsgridItem always depend on its parent width, default
childAspectRatio:1
that's why we get square shape, play withchildAspectRatio:width/height
-
-
William Pineda MHA almost 2 yearsActually what I'm looking for is that the children are rectangular and not square. However, when I tried to set a height greater than the width. Flutter did not take it and all the children continued to look square
-
Kaushik Chandru almost 2 yearsAdd childAspectRatio and set it to value less than 0. Like 0.7 or 0.8.
-
Kaushik Chandru almost 2 yearsEdited my answer. Please check