riverpod
riverpod copied to clipboard
Add a mechanism to pause rebuild widget when using ref.watch
Is your feature request related to a problem? Please describe.
Assume we have a StateNotifierProvider fooProvider.
Mulitple pages depend on fooProvider.
If we have a deep back stack like: PageA -> PageB -> PageC -> PageD
and all of these pages depend on fooProvider via ref.watch(fooProvider).
Then any state change of fooProvider will rigger all of these pages rebuild,
which has a performance problem.
Describe the solution you'd like
I am thinking of providing a new widget that can control the ref.watch behavior in the widget subtree (inspired by TickerMode).
The enable/disable logic can be implemented by ourselves or by riverpod if possible.
For example, control via the VisibilityDetector.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context Add any other context or screenshots about the feature request here.
Would it be alright to use TickerMode directly instead of adding something new? Such that when tickers are muted, ref.watch subscriptions are paused too
Would it be alright to use TickerMode directly instead of adding something new?
Sounds good! I hadn't noticed TickerMode was used in Overlay and other widgets before searching the flutter repo.