最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

riverpod - Provider listener body is not triggered when switching between two screens that listen to the same provider - Stack O

programmeradmin0浏览0评论

I have Flutter app with two screen: ScreenA and ScreenB. I am using RiverPod. I am listening to the same provider in both screens using ref.listen(). I run into a problem when navigating between both screens. Here is an example that cause problem.

  • Initially the app starts at ScreenA.
  • While in ScreenA, I update the provider. The listener in ScreenA is trigged as expected
  • I navigate to ScreenB. To my surprise, the body of the provider listener in ScreenB is not called when I enter into ScreenB. That means that ScreenB will not know the state of the provider when navigating from ScreenA to ScreenB.
  • If I navigate to ScreenB from ScreenC which does not listen to the the same provider, the body of the provider listener in ScreenB is triggered with no problems.

Is this a feature or a bug?

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论