简体   繁体   English

如何调整 Gridview flutter 中的网格大小?

[英]How do I sized of grid in Gridview flutter?

I want to change the dynamic size of children according to its array count.我想根据其数组计数更改子项的动态大小。 It is a way same like GridLayoutManger in android java. What I did in android(java)这与 android java 中的 GridLayoutManger 一样。我在 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;
            }

        });

By this I can change any grid size dynamically, I have my own formula for my layout.通过这个我可以动态地改变任何网格大小,我有我自己的布局公式。 So Is there any way to change size of any grid in Gridview Flutter?那么有没有办法改变 Gridview Flutter 中任何网格的大小? Please Don't suggest staggered GridView it is not for me.请不要建议交错 GridView它不适合我。

GridView does not support dynamic span, you can use spannable_grid GridView 不支持动态span,可以使用spannable_grid

you can wrap you grid inside container and set size of container using height and width您可以将网格包裹在容器内并使用高度和宽度设置容器的大小

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM