Home > Mobile >  How do I disable auto rotation on iOS and Android?
How do I disable auto rotation on iOS and Android?

Time:10-10

How do I make it so that in Flutter, auto rotation does not do anything but only widgets on button press can change the orientation?

For example I use MediaQuery to check Orientation, and then give a particular widget based on that. However my widget button press is what changes the orientation, not the device sensor. How can I achieve this?

CodePudding user response:

I have a solution for my use case (though I would still like to know how to disable the sensor orientation changes and keep it manual):

I have a boolean for the widget button press, and I have the condition as such:

MediaQuery.of(context).orientation == Orientation.portrait && !isFullScreen

This will then disable any auto rotation and only rotate when my full screen button is pressed.

CodePudding user response:

You can set the screen orientation in the configuration;

on ios platform: set iOS platform

on android platform: set android platform

  • Related