0

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)

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? Please Don't suggest staggered GridView it is not for me.

tailor
  • 373
  • 4
  • 19

2 Answers2

1

GridView does not support dynamic span, you can use spannable_grid

wjploop
  • 209
  • 2
  • 8
  • but in this we can not pass unknown size list – tailor May 11 '22 at 13:46
  • @tailor yes, this library is quite simple, it also does not support view recycle like ListView, you should be careful not to use it in the larger data list. – wjploop May 12 '22 at 02:02
0

you can wrap you grid inside container and set size of container using height and width

anggadaz
  • 342
  • 3
  • 13