CAZX
CAZX

Reputation: 11

How to get the screen size regardless of device orientation in flutter

How to get the Screen height in flutter regardless of the device orientation? As I know with the media query the height changes with the device orientation.

Upvotes: 1

Views: 1875

Answers (1)

Anas Nadeem
Anas Nadeem

Reputation: 887

You can check if orientation is landscape or portrait:

Orientation currentOrientation = MediaQuery.of(context).orientation;
if(currentOrientation == Orientation.portrait){
    height = MediaQuery.of(context).size.height
} else {
   height = MediaQuery.of(context).size.width
 }

Upvotes: 8

Related Questions