1. What is BuildContext in Flutter?
BuildContext is a handle or reference to the location of a widget within the widget tree, provided to every widget's build method. It allows widgets to access information about their position in the tree, find parent widgets using methods like findAncestorWidgetOfExactType, and access inherited widgets like Theme or MediaQuery. Every widget has its own BuildContext representing its specific location in the tree, which is why you can have multiple contexts in a single widget class. The context passed to the build method represents that widget's location, and you use it to navigate, show dialogs, access theme data, or read inherited widgets from ancestors in the tree. Common uses include Navigator.of(context) for navigation, Theme.of(context) for accessing theme data, MediaQuery.of(context) for screen dimensions, and Provider.of(context) for state management. Understanding BuildContext is crucial because many Flutter APIs require it, and using the wrong context can cause runtime errors or unexpected behavior.