📱 Flutter Intermediate

What is InheritedWidget in Flutter?

Answer

InheritedWidget is Flutter's built-in mechanism for efficiently propagating data down the widget tree. Any descendant widget can access the data by calling context.dependOnInheritedWidgetOfExactType(), and it will automatically be rebuilt when the data changes. It is the foundation that powers Theme, MediaQuery, Navigator, and most state management packages like Provider. While powerful, InheritedWidget has verbose boilerplate — packages like Provider exist to simplify working with it.