📱 Flutter Intermediate

What is InheritedWidget in Flutter?

Why Interviewers Ask This

Mid-level Flutter roles require deep understanding of this topic. Interviewers ask this to separate candidates who truly understand the mechanics from those who only know surface-level concepts.

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.

Pro Tip

Demonstrate both theoretical understanding and practical experience. Say what it is, then give an example of how you actually used it in a Flutter codebase.