Reputation: 11
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
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