Replies: 1 comment 2 replies
-
As a check I used the old approach and didn't have any trouble. I thought my @riverpod annotation was equivalent to this below. For completeness, I used this to call the update
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have the following Provider, which maintains the user position (lat and long). Within my user interface, this is called when the position changes.
ref.read(positionNotifierProvider.notifier).updateLocation(MyWeatherPosition(position.latitude, position.longitude));
The problem is every time this updateLocation is called, the build() is called, setting the state back to its original position. I expected this would only be called once if the user stayed on that page.
As a work-around used @Riverpod(keepAlive: true) (which ensures that build is only called once) but this is not preferred.
Am I doing something incorrect?
and within my ConsumerState class
Beta Was this translation helpful? Give feedback.
All reactions