0

I am a beginner level Flutter developer trying to resolve the issue with the Navigation stack. In the existing app:

  • When user logs in to the app, login api call is shooted
  • Homescreen is rendered with Navigator.popUntill method
  • All the APIs in the providers get shooted and the respective tabs/screens get filled with api data.

Now, I want to include Onboarding screens before Homescreen, so I made below changes:

  • Navigator.push method used to include Onboarding screens.
  • After onboarding screens are over, user clicks on "To app" button
  • On click of "To app" button, the login call is made again
  • User is redirected to Homescreen with Navigator.popUntill method.

But now the data from providers is lost as the respective screens do not show any data. I am pretty sure that something is going wrong with the Navigation stack when I use Navigator.push method to add Onboarding screens but I do not have much expertise in Flutter to debug the issue. Need help with restoring the provider data when navigating to Onboarding screens.

Gaurangi
  • 31
  • 2

1 Answers1

0

I think that the cause isn't in a navigation stack. Probably you placed Provider widget lower than navigation (MaterialApp). Try something like that or show your code for better understanding.

Provider(
  create: (context) => ClassThatCallsAPI(),
  child: MaterialApp(
    // Navigator placed here and any route will
    // get the same data from provider
    // and also can put some
  • Thank you for your answer. I was making a mistake by calling api twice and pushing the route to Homescreen again over a stack instead of popping up the route to Homescreen. – Gaurangi Mar 07 '22 at 14:47