ListView empty 50% of the time on initial app load

Actions & Logic

My app's main screen is a Google map widget on top, ListView of places on the bottom. Frequently when the app first runs, the ListView is empty when it shouldn't be. More details:

  • I have a BE query at the page level for a "places" Firestore collection.

  • The ListView is populated by a custom function (using "places" collection as input) that sorts places by distance among other things.

  • That page has OnPageLoad Actions:

    • (Delay - tested adding up to 2.5 sec delay here)

    • Move map center to app state variable LatLng (previously set)

    • (Delay - tested adding up to 2.5 sec delay here)

    • Update an app state variable with "rebuild current page"

When the main page loads, I'd say about 50% of the time it shows data as expected, the rest it shows the empty list widget. Moving the map at this point instantly and consistently updates the ListView as expected. It's just the initial page load that is inconsistent.

It seems there's some timing around PageLoad, the Firestore query, running the custom function & updating the ListView widget or rebuilding the page that I'm not getting right. I'm mainly testing on a real iOS device, not in test mode on an emulator.

Any ideas of how to get around this so the initial page load works consistently?

What have you tried so far?

Researching FF docs, searching community & other forums. Tried adjusting delays or adding the "page rebuild" events to see if that made a difference. Tested on different devices. Verifying data is correct in Firestore.

Did you check FlutterFlow's Documentation for this topic?
No
14 replies