flutter MediaQuery.of() called with a context that does not contain a MediaQuery. code example
Example: MediaQuery.of() called with a context that does not contain a 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.