Skip to content

Error when using pagination with realtime query #5442

Open
@tiagosilveiradev

Description

@tiagosilveiradev

Can we access your project?

  • I give permission for members of the FlutterFlow team to access and test my project for the sole purpose of investigating this issue.

Current Behavior

I have a component used by both pages and other components (such as inside a bottom sheet). This component receives a String parameter, which is used to filter data in a Firestore query with real-time updates enabled ("Listen for changes" toggled). The parameter can be null; if provided, the query applies the filter; otherwise, it does not.

When I call this component from a bottom sheet with a filter parameter, everything works as expected. However, after closing the bottom sheet and navigating to another page with the same component (but without the filter parameter), the query removes the filter. The issue arises because the query starts from the last known position of the query (or the last rendered component) rather than resetting properly.

After inspecting the generated code and debugging, I suspect the issue occurs because the nextPageMarker is not being reset when the bottom sheet is dismissed (or when pop() is called on the active page).

Here is a snippet of the code:

PagingController<DocumentSnapshot?, OrdensServicoRecord>
     _createListViewController(
   Query query,
   DocumentReference<Object?>? parent,
 ) {
   final controller = PagingController<DocumentSnapshot?, OrdensServicoRecord>(
       firstPageKey: null);
   return controller
     ..addPageRequestListener(
       (nextPageMarker) => queryOrdensServicoRecordPage(//Here
         queryBuilder: (_) => listViewPagingQuery ??= query,
         nextPageMarker: nextPageMarker,
         streamSubscriptions: listViewStreamSubscriptions,
         controller: controller,
         pageSize: 25,
         isStream: true,
       ),
     );
 }
}

If I disable the "Listen for changes" option, it does not happen.

Expected Behavior

When the component (or bottom sheet) containing the query is dismissed, and the user navigates to another page that also includes the same component, the query should start from the beginning. It should not continue from the last item that was loaded on the previous page or component.

Steps to Reproduce

  1. Create a component with a parameter;
  2. Put a listview inside of this component;
  3. Put a Firestore query at this listview;
  4. Pass this parameter to the query and check the options "Listen for Changes", "Ignore empty filter values" and "Enable Infinity Scroll"
  5. Create another component with the same parameter of the last component;
  6. Put the query component inside of the new component;
  7. Create a page;
  8. Put the query component inside of this page passing null as a parameter
  9. Create another page;
  10. Inside of the another page create two buttons, one to call a bottomsheet passing a parameter and another navigating to the other page with the query component
  11. Start your app, click to open the bottomsheet
  12. Dismiss the bottomsheet
  13. Navigate to the other page

Reproducible from Blank

  • The steps to reproduce above start from a blank project.

Bug Report Code (Required)

IT4kz/Hqx89Prttc15PTbcZKo2E6Jn56TL07r+5xb0gvIrbyOu9/PffOQBZWYMTiSlNhHFabgj0d7s7GjoSTFfUnFzqaGq5z+sx6ERXvTXq8SpSyPKjpenwnRJ5QJ0id1J6Z2yJTKvNfdGAb3EOpN9itTT7tCZ+/Zwh9f6PHaOI=

Visual documentation

Environment

- FlutterFlow version: 5.2.20
- Platform: Web
- Browser name and version: Chrome 132.0.6834.197 
- Operating system and version affected: Windows 11

Additional Information

It is causing problems to my costumers since it is showing incorrect information, so they think that losses some data and opens a support ticket, and, we need realtime data at all instances of this component, so, disabling realtime is not possible.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions