Valerie Ackon
Valerie Ackon

Reputation: 1

What to use instead of MediaQueryData mediaQueryData = MediaQueryData.fromWindow(ui.window);?

I am relatively new to flutter, and this is what I was using in my project to get the device's metrics:MediaQueryData mediaQueryData = MediaQueryData.fromWindow(ui.window);. However, in VSCode, I keep getting a message saying this has been been deprecated and I cannot quite figure out what to do instead.

I tried reading the flutter documentation, but it is not completely clear what to do, at least to me.

Upvotes: 0

Views: 449

Answers (2)

Uwe Post
Uwe Post

Reputation: 515

I think we should use:

MediaQueryData.fromView(View.of(context));

Upvotes: 0

Mouaad Ouajib
Mouaad Ouajib

Reputation: 103

to get the device metrics use :

MediaQuery.of(context).size.height
MediaQuery.of(context).size.width

Upvotes: -1

Related Questions