Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup corect scrollOffsets when on beggining of the list #302

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

centy
Copy link

@centy centy commented May 3, 2023

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

This prevents messing up elements that causes holes in view
@centy
Copy link
Author

centy commented Jun 4, 2023

@letsar Are you still supporting this package?

@letsar
Copy link
Owner

letsar commented Jun 5, 2023

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.

@centy
Copy link
Author

centy commented Jun 5, 2023

@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

@centy
Copy link
Author

centy commented Dec 16, 2023

@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.

@glemartret
Copy link

glemartret commented Aug 2, 2024

I can confirm that this fixes the issue with empty spaces in Masonry grid. Could this be integrated in the public version ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants