Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Width & Height of MediaQuery.of(context).size are zero

Tags:

flutter

dart

is there anyone facing the same issue in flutter 3.10.1, Dart 3.0.1? The

MediaQuery.of(context).size.width 

and

MediaQuery.of(context).size.height 

are always 0.

MediaQuery.of(context).size.width 

and

MediaQuery.of(context).size.height 

had worked with no issue in previous Flutter 2.19, but i get this issue after upgrade.

like image 576
AlphaDev Avatar asked Aug 30 '25 17:08

AlphaDev


1 Answers

I have the same issue - MediaQuery.of(context).size.width return zero and it works in Flutter 3.7.12 but stop works in 3.10.5. In my case it happens cause one of my widgets was wrapped with MediaQuery:

  return MediaQuery(
    data: const MediaQueryData(),
    child: MaterialApp(home: home),
  );

I just removed this MediaQuery and it works

like image 170
anber Avatar answered Sep 02 '25 06:09

anber