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

Prepend is ignored if page size is less than prefetch index #8

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dinaraparanid
Copy link

Fixes #7

Comment on lines 477 to 479
reverse ? index >= itemCount - fetchIndex : index <= fetchIndex;
final nearBottom =
reverse ? index == fetchIndex : index == itemCount - fetchIndex;
reverse ? index <= fetchIndex : index >= itemCount - fetchIndex;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thank you for the PR but this will also trigger notification for all the items after the prefetch item. A better solution would be to count the items of last or first page based on reverse and then match it with
min(fetchIndex, length).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, thank you for reply! It seems that checking exact item index with == will still not work even for min(fetchIndex, length). There is an example that will break it:

  1. Suppose id of message is the key of page (e.g. start page from message with id = ?)
  2. Initial key = 20 (message id), page size = 45, prefetchIndex = 22
  3. We cannot use == with min(fetchIndex, len) since we have not reached item with index 22 (because we are loaded page from item=20, but it has initial index = 0, meaning that we have to scroll down to item 20+22=42 to trigger prepend operation)

Solution seems to be straightforward: in PageFetcher we disallow to trigger multiple _doLoad calls (we cannot do it on Ui, because of WidgetsBinding.instance.addPostFrameCallback { pager.load(...) }), which will protect pager from multiple requests of items that have passed fetchIndex

@xsahil03x
Copy link
Owner

Hey @dinaraparanid , can you try this PR #9 and check if this fixes your issue? Thanks

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.

Prepend is ignored if page size is less than prefetch index
2 participants