flutter_staggered_grid_view
flutter_staggered_grid_view copied to clipboard
cacheExtent
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:
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,
@letsar Think this is a feature the package would benefit greatly from. Are there any plans to continue development?
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.
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
Can you test with the latest 0.5.0 preview? https://pub.dev/packages/flutter_staggered_grid_view/versions/0.5.0-dev.1
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
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