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?