Replies: 2 comments 6 replies
-
You should be using What is happening is that the watch in MyApp is causing the MyView to get rebuilt every time the state changes because it is watching the state, which creates a new home every time. Since you are on the home route, the home route gets rebuilt and the new value gets read. When you then go to a different route, MyApp then rebuilds whenever the state changes, and updates what the home route's value should be, but you are on a different route, so you don't have the updated value passed in, and MyView doesn't rebuild since it is not watching the myState value. If you do ref.watch in the MyView widget it will update anytime the myState updates. |
Beta Was this translation helpful? Give feedback.
-
Hello! This isn't related to Riverpod and is instead an edg-case with Navigator.push / showDialog. When you do: Navigator.push(SomeWidget(value)) then You may want to use Navigator 2 instead, which, with its declarative syntax, would correctly pass the new parameter to the route: Navigator(
pages: [
if (something)
MyView(value), // correctly updates MyView when "value" changes
]
) |
Beta Was this translation helpful? Give feedback.
-
Hi,
With
flutter_riverpod-1.0.0-dev.10
I face a strange behaviour on the following code. Basically as soon as a route is pushed the value of the state above the MaterialApp is not updated anymore. Am I using riverpod in a wrong way or is it a bug?When the app is loaded every tap on "Increment" will increment the 2 displayed values until "Push route" is tapped. Then only the second value (retrieved from
ref.read(myState)
) is updated.Beta Was this translation helpful? Give feedback.
All reactions