flutter_staggered_grid_view icon indicating copy to clipboard operation
flutter_staggered_grid_view copied to clipboard

Nested MasonryGridView inside a column cause Exception

Open koaladaddy opened this issue 3 years ago • 3 comments

Hi, Nested MasonryGridView inside a column cause Exception: FlutterError (Vertical viewport was given unbounded height.

I am using version 0.6.0.

body: SingleChildScrollView( child: Material( child: Column( children: [ MasonryGridView.count( crossAxisCount: 4, mainAxisSpacing: 4, crossAxisSpacing: 4, itemBuilder: (context, index) { return Tile( index: index, extent: (index % 5 + 1) * 100, ); }, ),],),),)

If I add two properties: `` shrinkWrap: true, physics: NeverScrollableScrollPhysics(),

`` I can not navigate to this page anymore.

Thanks for any advice.

koaladaddy avatar Mar 10 '22 00:03 koaladaddy

It seems like you gave a Column an infinite height, I don't see why you need a SingleChildScrollView and a Column here. Why don't you use only a MasonryGridView.count?

letsar avatar Jul 10 '22 09:07 letsar

I face same issue, I want to use Colum + SingleChildScrollView for add some thing like header abrove MasonryGridView (or footer after MasonryGridView).

For GridView, it work after add shrinkWrap: true and physics: NeverScrollableScrollPhysics(),

Can MasonryGridView do same thing?

dodatw avatar Aug 05 '22 09:08 dodatw

Adding shrinkWrap to true and physics to NeverScrollableScrollPhysics is a signal that we are in the wrong direction.

To achieve these kind of particular effects, you can use a CustomScrollView. In the first sliver you will add your header (wrapped with a SliverToBoxAdapter if it's a box), then you can use a SliverMasonryGrid as the second child.

letsar avatar Nov 01 '22 10:11 letsar