letsar / flutter_staggered_grid_view

A Flutter staggered grid view
MIT License
3.14k stars 510 forks source link

Very poor performance with SliverStaggeredGrid.countBuilder on ^3.0.0 #113

Closed orible closed 2 years ago

orible commented 4 years ago

Environment information: Flutter version 1.12.13+hotfix.7 Dart version 2.7.0 Platform: android-29, build-tools 29.0.3

Testing devices: Android device on API level 29 Android emulator for API level 29

Runtime environments tested: Debug Profile

SliverStaggeredGrid.countBuilder(
    itemCount: this.widget.data.length,
    crossAxisCount: 2,
    staggeredTileBuilder: (index) {
        return new StaggeredTile.fit(1);
    },
    itemBuilder: (context, index) {
        return ListingCard(data: this.widget.data[index]);
    }
)

~~The issue: When scrolling scrolling down a list of items, SliverStaggeredGrid executes itemBuilder() for every item in its data set whenever a single item becomes visable in the viewport, this appears to cause unacceptable performance degredation on both UI and logic threads, 10fps etc.~~

A large number of cells are rebuilt each frame when scrolling.

It also seems to agressively call staggeredTileBuilder() though I'm not sure if that's by design.

asadmubashr commented 1 year ago

I want to use StaggeredGridView in latest version like we used in 0.3.4 but new StaggeredGridView seems different