flutter_staggered_grid_view
flutter_staggered_grid_view copied to clipboard
Setup corect scrollOffsets when on beggining of the list
When using MasonryGridView with unique keys for each item like below:
child: MasonryGridView.count(
mainAxisSpacing: 10,
crossAxisSpacing: 10,
itemCount: state.imagesCount,
itemBuilder: (context, index) => ImageTile(
key: Key(state.images[index].imagePath),
pictureInfo: state.images[index],
viewType: filter.type,
),
crossAxisCount: 2,
),
and order of items changes then layout has holes mostly on second column. In my case any image can be moved to beginning of the list. So the newly moved image beaks logic that calculates offsets.
That fix prevents holes in image stream to appear
@letsar Are you still supporting this package?
Hi @centy, yes I still maintain this package but I don't have a lot of time at the moment to do it properly. Can you explain me why this PR is fixing this issue? I don't really see the link between what you described and the fix.
@letsar Issue appears if you have list of items, with keys. For some reason you want to reorder them, my case was to move any element to the beginning of the list. That action causes issue like this: before: 12 34 56
now move 3 on 1 position 3 <-empty space 12 45 6
Code when rebuilding offsets, calculates right offset starting not from 0. It is 100% reproducible
@letsar Can you merge it or fix it? I am keeping changes on my branch. I would like to back to use stock version of the widget.
I can confirm that this fixes the issue with empty spaces in Masonry grid. Could this be integrated in the public version ?