Search code examples
androidflutterdartiso

how to use calculate height and width using MediaQuery?


Suppose I have a container with height 60. How this 60 can be written in mediaquery?

example code:

Container(height:60,)

I want this container looks like having 60 as height but in responsive way.


Solution

  • You can Try this:

    var size = MediaQuery.of(context).size;
    
    Container(height:size.height * 60/580,);
    

    here 60 is the height you prefer and 580 is the height of your device in ui design.