1. What is the purpose of InheritedWidget in Flutter?
InheritedWidget is Flutter's mechanism for propagating data efficiently down the widget tree, allowing descendant widgets to access shared data without explicitly passing it through every widget in between. When you call context.dependOnInheritedWidgetOfExactType, Flutter establishes a dependency, and the widget automatically rebuilds when the InheritedWidget's data changes. This solves the prop drilling problem where you'd otherwise need to pass data through many intermediate widgets that don't use it. InheritedWidget is the foundation for many state management solutions - Theme, MediaQuery, Navigator, and Provider all use InheritedWidget under the hood to share data across the tree. InheritedWidget is more efficient than passing data through constructors because only widgets that explicitly depend on the data rebuild when it changes, not every widget in the path. However, using InheritedWidget directly is verbose and error-prone, which is why packages like Provider wrap it with a simpler API while maintaining the efficiency benefits.