What is the BuildContext in Flutter?

Answer

BuildContext is a handle to the location of a widget within the widget tree. Every build() method receives a BuildContext, which is used to look up ancestor widgets like Theme.of(context), MediaQuery.of(context), and Navigator.of(context). It is important to understand that BuildContext is tied to the widget's position — using a stale or wrong context (e.g., from a disposed widget) is a common source of bugs.