Race condition issue - What is the best way to verify if a user has completed onboarding?

Actions & Logic

Here's my setup:

  • When a user taps the "Sign Up" button or uses "Sign Up With Google / Apple," they are redirected to the onboarding page.

  • However, there’s a potential edge case:
    If a user signs in, lands on the onboarding page, exits the app, and then reloads it, they are redirected to the home page without completing the onboarding process.

  • Proposed Solution (but facing a critical issue):

    • I currently use an on page load action on the home page (the page users land on after authenticating on login). This action:

      1. Checks if the user has completed onboarding (using a Boolean field, e.g., isOnboarded, stored in Firebase).

      2. If isOnboarded is true, the user stays on the home page.

      3. If isOnboarded is false, the user is redirected to the onboarding page.

    • Issue:
      Sometimes, Firebase doesn’t fetch the isOnboarded value quickly enough before the app determines whether to show the onboarding flow or not. This creates a race condition, where:

      • Users who have already completed onboarding may still be redirected to the onboarding page due to the delay in retrieving the Boolean value.

    • What is the best way to address this race condition? Are there alternative approaches or best practices?

What have you tried so far?

On page load check isOnboarded boolean

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