-
Notifications
You must be signed in to change notification settings - Fork 219
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
Try to fix double fetch #366
Conversation
@@ -260,7 +261,7 @@ class _PagedLayoutBuilderState<PageKeyType, ItemType> | |||
// This behaviour is okay because we make sure not to excessively request pages. | |||
final hasPassedTrigger = index >= triggerIndex; | |||
|
|||
if (_hasNextPage && hasPassedTrigger) { | |||
if (_hasNextPage && hasPassedTrigger && !_state.isLoading) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one i didn't understand why it is needed, why this method is called twice is a mystery.
@@ -162,7 +162,7 @@ class _PagedLayoutBuilderState<PageKeyType, ItemType> | |||
@override | |||
void initState() { | |||
super.initState(); | |||
if (_state.status == PagingStatus.loadingFirstPage) { | |||
if (_state.status == PagingStatus.loadingFirstPage && !_state.isLoading) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This add a little more flexibility : if initial state is already loading, why start a new one.
@@ -172,7 +172,8 @@ class _PagedLayoutBuilderState<PageKeyType, ItemType> | |||
covariant PagedLayoutBuilder<PageKeyType, ItemType> oldWidget) { | |||
super.didUpdateWidget(oldWidget); | |||
if (oldWidget.state != widget.state) { | |||
if (_state.status == PagingStatus.loadingFirstPage) { | |||
if (_state.status == PagingStatus.loadingFirstPage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I printed oldWidget.state and widget.state
I/flutter (15329): PagingStateBase<int, String>(pages: null, keys: null, error: null, hasNextPage: true, isLoading: false)
I/flutter (15329): PagingStateBase<int, String>(pages: null, keys: null, error: null, hasNextPage: true, isLoading: true)
As you can see, _fetchNextPage() will call again _fetchNextPage() when isLoading is true.
The fetch function must deduplicate fetch calls for the reason mentioned in the issue. |
We have difficulty to upgrade to
infinite_scroll_pagination: 5.0.0
due to this issue : #365