FlutterFlow / flutterflow-issues

A community issue tracker for FlutterFlow.
130 stars 26 forks source link

Infinite scroll show same page twice #4713

Closed TolinhoCTO closed 2 weeks ago

TolinhoCTO commented 3 weeks ago

Can we access your project?

Current Behavior

Hi,

So I am making an api call to populate a listview, my api call take pagination to show a limited number of elements. On flutterflow I enabled the infinite scroll view to load one page at the time. The problem is when reaching the end of the list it loads the first page again. Even tried with longer list and the same problem appears so it loads like this page: 1,2,3,4,1

I precise that even without other parameters the problem still happens, even without pull to refresh. I have seen someone going around this problem but for a firestore collection and not an api call. Which is looking like a bug or at best a lack of information on how to set up infinite scroll

Expected Behavior

I would like each page to only load once in infinite scroll.

Steps to Reproduce

  1. Create a listview and populate it with api call
  2. Ensure you have pagination on your api call
  3. Enable infinite scroll
  4. Load the page

Reproducible from Blank

Bug Report Code (Required)

ITFXi/Hl34Z1oeZE1rqAK8ZsniYwGUwbUOc7j9VEGAsjCePqEIl3O+PBXFdocuqHYAliGWf+rEk1wtbOi+LpIfICGz+ZfLp41ap9UxDgLUWWacm7PpC0f3QmBfNRG2aC0J6nuRQkBMZtL2QMwU+DfeyQb3qCf9qOYwx5e6fDbOY=

Visual documentation

Capture d’écran 2024-10-28 à 10 58 36 Capture d’écran 2024-10-28 à 10 58 32

https://github.com/user-attachments/assets/d5a7c5d9-0c49-4554-b60e-479dbf6476db

Environment

- FlutterFlow version: FlutterFlow v5.0.8+ released October 22, 2024
Flutter version is 3.24.2
- Platform: Web, IOS, android
- Browser name and version: Chrome 129.0.6668.101
- Operating system and version affected: All

Additional Information

No response

Alezanello commented 3 weeks ago

Hello!

In FlutterFlow, the infinite scroll index starts at 0. To start from 1 instead, you can add a code expression to the infinite scroll variable that increments the index value by 1. This adjustment ensures that the pagination starts at 1 and prevents the first page from repeating.

image.png
TolinhoCTO commented 3 weeks ago

Already tried it, and not working

TolinhoCTO commented 3 weeks ago

It doesn't explain the fact that it loads 1,2,3,4 and 1 again

Alezanello commented 3 weeks ago

You can take this project as an example: https://app.flutterflow.io/project/qa-1385-b9jn2m

This is the result:
https://qa1385-photos.flutterflow.app/

TolinhoCTO commented 3 weeks ago

yes but you have ilimited photos on this example how can you ensure that at the end it doesn't load the first page again ?

TolinhoCTO commented 3 weeks ago

Okay it worked thank you a lot sorry for the problem but for anyone who comes here don't do code expression like this: var1(next index) + 1 but do var1(next index) + var2(1)

Alezanello commented 2 weeks ago

I’m glad everything is working as expected now! I’ll go ahead and close this issue, but if you encounter anything else, please don’t hesitate to open a new one!