Flutter Gridview in Column. What's solution..?

后端 未结 5 1293
小鲜肉
小鲜肉 2021-02-02 09:16

I have a problem with gridview and column. In this case, i want put an image in upper of gridview. Please give me a solution..

return new Container(
  child: new         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-02 09:47

    If Column is the parent of GridView then it will give rendering issue as It happens because Column and GridView both take the entire space of the screen individually which is there default behavior(Default axis of scrolling is Vertical).

    Solution:

    To solve the above problem we have to disable scrolling of GridView, This can be possible by shrinkWrap and physics property

    shrinkWrap:true - With this GridView only occupies the space it needs

    physics: NeverScrollableScrollPhysics() - It disables scrolling functionality of GridView, which means now we have only SingleChildScrollView who provide the scrolling functionality.

    Code:

    SingleChildScrollView
       Column
            GridView(
                    shrinkWrap: true,
                    physics: NeverScrollableScrollPhysics(),
                    //...
                    )
    

提交回复
热议问题