1

I create a GridView in flutter with the shrinkWrap set to true (which I expect the GridView will be shrink exactly as the content's size).

But in my demo (Green background color indicates GridView , and the Red Color indicates the content widgets in the GridView)

I found that , the GridView will not shrink as small as possible to it's contents. The GridView's height is a bit larger than the GridView's content height .

What makes the GridView not shrink as small as possible?

enter image description here

ximmyxiao
  • 2,622
  • 3
  • 20
  • 35

1 Answers1

1

OK, after debugging with the source code . I found the reason to this problem:

Seems when you create a ListView & GridView with a null padding passing to it . Flutter SDK will make a Inset (RenderSliverPadding)during the layout of the ListView&GridView.

So the way to remove this padding is set a padding in the ListView&GridView's constructor

enter image description here

ximmyxiao
  • 2,622
  • 3
  • 20
  • 35