ftognetto / riverpod_infinite_scroll

A plugin for Flutter's infinite_scroll_pagination that works with Riverpod.
MIT License
27 stars 23 forks source link

Duplicate page loads #35

Open jonjomckay opened 1 year ago

jonjomckay commented 1 year ago

Hello. I occasionally seem to get the first page of results loading twice, and I've narrowed it down to this line of code.

It appears that the method is called twice (as expected, I think), but previousPageKeys isn't yet populated on the second call. The first page key only seems to get added to previousPageKeys after _load is called the second time.

pmkod commented 1 year ago

Hello. I occasionally seem to get the first page of results loading twice, and I've narrowed it down to this line of code.

It appears that the method is called twice (as expected, I think), but previousPageKeys isn't yet populated on the second call. The first page key only seems to get added to previousPageKeys after _load is called the second time.

For me too, the page is reloaded twice, when I leave it and return to it.

pmkod commented 1 year ago

I'm sorry, it was due to poor implementation on my part. In your load function, you check the list of previousKeys using the .contains function. It turns out that I was using a specific type for my keys and I didn't overload the == operator to get a good equality comparison. I used the equatable library for this, and everything works correctly now. Thanks for your library.

Arjun544 commented 6 months ago

@pmkod Can you please share some code?