来自提供商的 API 数据似乎在导航期间丢失
我是一名初级 Flutter 开发人员,试图解决导航堆栈的问题。 在现有的应用程序中:
- 当用户登录到应用程序时,会触发登录 api 调用
- 主屏幕使用 Navigator.popUntill 方法呈现
- 提供程序中的所有 API 都会被触发,并且相应的选项卡/屏幕会填充 api 数据。
现在,我想在主屏幕之前包含入职屏幕,因此我进行了以下更改:
- Navigator.push 方法用于包含入职屏幕。
- 入门屏幕结束后,用户单击“到应用程序”按钮
- 单击“到应用程序”按钮时,再次进行登录调用
- 用户将使用 Navigator.popUntill 方法重定向到主屏幕。
但现在来自提供商的数据丢失了,因为相应的屏幕不显示任何数据。当我使用 Navigator.push 方法添加 Onboarding 屏幕时,我非常确定导航堆栈出了问题,但我在 Flutter 方面没有太多专业知识来调试该问题。在导航到入职屏幕时需要恢复提供商数据的帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为原因不在导航堆栈中。可能您将
Provider
小部件放置在导航 (MaterialApp
) 下方。尝试类似的方法或显示您的代码以更好地理解。
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.