r/FlutterDev • u/RandalSchwartz • Sep 27 '26
Discussion How a rejected 2019 Flutter PR forced Riverpod to leave the widget tree
Most of us know Provider was built on InheritedWidget, but I recently revisited the exact mechanical reason Rémi had to abandon it to create Riverpod.
It comes down to a fundamental design choice in dependOnInheritedWidgetOfExactType: the Flutter framework never unregisters a dependency once registered.
If you read state conditionally behind an if check, that element stays locked in InheritedElement._dependents until it unmounts. Even after the condition flips to false, that widget keeps rebuilding on every single ancestor change forever.
In May 2019, Rémi opened PR #33213 to add an unlisten hook to InheritedElement. Hixie closed it to avoid adding overhead to the hot reconciliation loop. Because Provider had no way to know when widgets stopped listening, autoDispose was impossible—forcing Rémi to hoist state completely out of the tree.
Looking back, it’s wild how much of the state management wars over the last five years really just came down to working around that one framework limitation.
Did you ever run into those conditional "ghost rebuilds" in Provider back in the day?
34
u/Swefnian Sep 27 '26
Ok that’s legitimately interesting. I never understood why the creator of the most popular state management library at the time would suddenly create a new one.
At the time my reaction was “We already have provider, why do we need this!”
5
u/into_void Sep 27 '26
Nice. I wasn't even aware of it. I always thought riverpod is about immutability. On the other hand riverpod is massive and implements piecewise solutions for piecewise problems or cases. I could only get started because of Getx though it is very controversial and hated by flutter purists.
13
u/_KryptonytE_ Sep 27 '26
Your insightful backstories are so amazingly relatable. Such a good time to be building with the community. Thank you for these random gems sensei Randal. You made my day.
Cheers!!! 🥂
3
u/venir_dev Sep 28 '26
yeah we've mentioned this as a community:
https://riverpod.dev/docs/from_provider/motivation
3
u/bigbott777 Sep 27 '26
An inherited widget, probably, must have for a framework like Flutter. But build state management on it? Just an imagination of data passing down the widget tree makes me dizzy. Just use a service locator; problem solved.
2
u/Revolutionary-Hat-88 Sep 28 '26
Hixie made the right call
3
u/[deleted] Sep 28 '26
[removed] — view removed comment
1
u/[deleted] Sep 30 '26
[removed] — view removed comment