Hello Guys how are you all ? Hope you all are fine. When I run my flutter project Suddenly I got Flutter Error: MediaQuery.of() called with a context that does not contain a MediaQuery In Flutter in my stacktrack.
Everything was working fine, But as I use MediaQuery.of(context).size; in my StatelessWidget Or StateFulWidget I am Facing This Above Error.
What is Error ?
When I Try to use MediaQuery.of(context).size; In My StateFul Or StateLess Widget I am Faced Below Error In My Stack Track.
Flutter Error: MediaQuery.of() called with a context that does not contain a MediaQuery
Here is my Code.
import 'package:flutter/material.dart';
void main => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return new MaterialApp(
home: new Scaffold(
// Rest of my code
),
);
}
}
Solutions
Here is All Possible Solution added please visit [Solved] Flutter Error: MediaQuery.of() called with a context that does not contain a MediaQuery
Top comments (0)