flutter_staggered_grid_view icon indicating copy to clipboard operation
flutter_staggered_grid_view copied to clipboard

cacheExtent

Open danieramiz opened this issue 5 years ago • 6 comments
trafficstars

Hey all Your plugin is working really well so far, but I have an issue when I scroll up or down each element shows as loading, just like trying to be painting again.

check the image:

Captura de Pantalla 2020-03-05 a la(s) 12 05 36

This happened to me before when I used the Flutter GridView.count widget. I fixed the issue using the cacheExtent property.

It is possible to use cacheExtent on "flutter_staggered_grid_view" ? or is there any other alternative?

Here is my current code:

StaggeredGridView.countBuilder( crossAxisCount: 4, itemCount: snapshot.data.length, itemBuilder: (BuildContext context, int index) => Container( child: ResumenFactura(snapshot.data[index]),), staggeredTileBuilder: (int index) => new StaggeredTile.fit( 2), mainAxisSpacing: 10.0, crossAxisSpacing: 10.0, addAutomaticKeepAlives: true, );

Thanks,

danieramiz avatar Mar 05 '20 18:03 danieramiz

@letsar Think this is a feature the package would benefit greatly from. Are there any plans to continue development?

Nash0x7E2 avatar May 14 '20 00:05 Nash0x7E2

I'm not sure the cacheExtent is the solution. For me addAutomaticKeepAlive should do. I want to improve this package but I'm stucked with the dynamic resizing. It's very hard to built something performant because of this feature.

letsar avatar May 14 '20 05:05 letsar

As @letsar say try to use automatic keep alive.

In this comment https://github.com/letsar/flutter_staggered_grid_view/issues/15#issuecomment-706678027, I explain how to create a widget that using it inside StaggetredGridView, it should keep their state.

Also for the loading indicator, I would suggest you add it inside a ConstrainedBox with a minHeight

jamesblasco avatar Oct 11 '20 10:10 jamesblasco

Can you test with the latest 0.5.0 preview? https://pub.dev/packages/flutter_staggered_grid_view/versions/0.5.0-dev.1

letsar avatar Dec 12 '21 18:12 letsar

Keeps happening in 0.6.1

I use a MasonryGridView.count() to display a list of images loaded from the network (using a CachedNetworkImage) but every time I scroll the layout jumps all over the place as images are loaded/unloaded

MasonryGridView.count(
            addAutomaticKeepAlives: true,
            cacheExtent: 200.0,
            crossAxisCount: 2,
            mainAxisSpacing: 4,
            crossAxisSpacing: 4,
            itemCount: stuff.length,
            itemBuilder: (context, index) {
              debugPrint('Item build: $index');
              return MAT.Image.network(
                  stuff[index]['imageHighUrl'], stuff[index]['thumbnailData']);
            },
          );

Same thing keeps happening regardless of what I set addAutomaticKeepAlives to, or whether I use the count or builder constructor

kerberjg avatar May 27 '22 15:05 kerberjg

As @letsar say try to use automatic keep alive.

In this comment #15 (comment), I explain how to create a widget that using it inside StaggetredGridView, it should keep their state.

Also for the loading indicator, I would suggest you add it inside a ConstrainedBox with a minHeight

As you mentioned in the comment you left in the previous thread, the imitation from the mixin helped solve the problem with saving the image state. Thank you

fox-avokadik avatar Dec 14 '23 20:12 fox-avokadik