-
Notifications
You must be signed in to change notification settings - Fork 213
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
Refresh calls ignored when other refresh in progress #338
Comments
was looking for this as well. I saw a thing on the paging controller called |
I also have this issue now. Not sure how to solve it. |
I have found a pretty minimalistic way to fix this issue. The root of this problem is that
|
using this version causing duplicates. |
No, is the short answer, but I do have a solution you can try see my last sentence. What makes it more frustrating is that addPageRequestListener triggers the fetch immediately consider this scenario: I think maybe having a hasListeners method for both status and page request listeners would be a nice thing to add. But i would prefer that addPageRequestListener just didnt fire until i told it to or if i could configure the way it behaves in regards to which operator is used I'd prefer a debounce to what feels like a throttle. My solution you can try is I think in your original scenario outlined above you are changing filters I would expect the list not to be refreshed but to be completely new in which case you can just call fetchPage(0); |
looks like this also causes duplicates |
The next version of the package, v5, fixes this issue, as it allows to interrupt previous operations of the controller when a refresh is called. You can see the code for that on the new-gen branch. As soon as I have written a migration guide, it will be released. |
@clragon I updated to the latest available I successfully migrated the calling code to follow your instructions here: https://github.com/EdsonBueno/infinite_scroll_pagination/blob/new-gen/example/example.md I know you're still working on this, but I wanted to test anyway. My calling code is 100% aligned with your example code. My page provides a search field that needs to refresh the paging controller (and cancel any pending refresh before if necessary): return TextField(
controller: itemController,
decoration: InputDecoration(
border: const UnderlineInputBorder(),
labelText: 'Enter a name here',
prefixIcon: const Icon(Icons.search)),
onChanged: (text) {
_pagingController.refresh();
notifyListeners();
}
); For state synchronization, I don't use So, the migration is smooth (it builds and provides the same functionality as before), but Is there any other function I need to call besides |
The new version is conceptualized to allow customizing your state managment to 100%, However, to benefit from the interruptable requests, you either need to implement a mechanism like in PagingController or use PagingController after all. PagingController is already a ChangeNotifier internally, so you can use it directly with a ValueNotifierProvider instead of creating another extra controller. You can also extend PagingController however you like, as we have written the class with that in mind. This is to solve the whole "having two controllers" problem that the package runs into currently. I will take a bit of extra time to look into whether the interruption mechanism works correctly. |
What I just meant is that instead of doing this: setState() { _searchTerms = searchTerms; }
pagingController.refresh(); I am just doing: _searchTerms = searchTerms;
model.notifyListeners(); // instead of setState()
pagingController.refresh(); My whole page is enclosed in a ...
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider( // wrap everything in a ChangeNotifierProvider
create: (context) => model,
child: Consumer<MyModel>(builder: (context, cart, child) { // and let the whole widget tree consume it
return PagingListener(
controller: pagingController,
builder: (context, state, fetchNextPage) => PagedSliverList<int, Photo>(
state: state,
fetchNextPage: fetchNextPage,
builderDelegate: PagedChildBuilderDelegate(
animateTransitions: true,
itemBuilder: (context, item, index) => ImageListTile(item: item),
),
),
);
} When I execute this code, infinite scroll does work visually speaking when I scroll down, but I get plenty of exceptions in the console:
Additionally, |
I am also getting the same exceptions with the sample as-is provided here (new-gen branch): https://github.com/EdsonBueno/infinite_scroll_pagination/tree/new-gen/example I am using a Flutter web target. Testing with Chrome. |
I get the same issue Its when it tries to get the value
here where it calls notifyListeners
|
Thank you for your report. We have committed a fix for these two issues. |
Hello,
I need to be able to refresh page (after filtering) quite frequently (using barcode scanner), but once one "refresh" is in progress and I execute another one, the 2nd gets ignored.
I've tried several approaches like using buffer listener (triggering another refresh after complete status, but refresh is not triggered in listener at all) and another techniques, but with no luck.
Is there any option how to cancel current refresh operation and trigger new one?
Thank you.
The text was updated successfully, but these errors were encountered: