如何在Gridview颤振中调整网格的大小?



我想根据它的数组计数改变子元素的动态大小。它的方式与android java中的gridlayoutmanager相同。android(java)

GridLayoutManager mng_layout = new GridLayoutManager(this, 4/*In my case 4*/);
mng_layout.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
@Override
public int getSpanSize(int position)
{
int mod = position % 6;
if (fullSizeGrid(position))
return 4;  //one grid take space of four grid
else if (position == 0 || position == 1)
return 2;
else if (position < 6)
return 1;
else if (position<18)
{
return method1(mod);
}
else if (position>18)
{
return method2(position);
}
else
return 1;
}
});

通过这个我可以动态地改变任何网格大小,我有我自己的布局公式。有没有办法改变Gridview Flutter中任何网格的大小?请不要建议交错的GridView,它不适合我。

GridView不支持动态span,你可以使用spannable_grid

你可以在容器内包裹网格,并使用高度和宽度设置容器的大小

最新更新