MediaQuery.के() कहा जाता है के साथ एक संदर्भ शामिल नहीं करता है कि एक MediaQuery.
You need a MaterialApp or a WidgetsApp around your widget. They provide the MediaQuery. When you call .of(context) flutter will always look up the widget tree to find the widget.