Lock Device Orientation in Flutter
We may have noticed, in some mobile apps, we just can’t rotate them. Even if auto-rotation (or whatever thing it is) on, we can’t rotate the phone while we’re using those apps. To be honest, I first used this feature, just because I was too lazy to create a UI for landscape mode 😊. So I locked it and people will never be able to on Landscape mode.
In Flutter, It is quite easy to implement this.
First of all, we have to import
Then, In our Apps main function, just before we call
runApp, call the below code,
This will lock our app’s orientation to portrait mode.
And if you wanna lock the orientation to landscape mode,
you can change
I think you found something useful here. You can read more posts related to Flutter, by going to this section.
I’m always open to suggestions!
If you’re feeling too generous, you can support me through Buy Me a Coffee.
Finally, if you found this helpful, please share this within your reach so that more people can benefit from this. And Follow me on Twitter for getting more posts like these 😉.
Join my email list to get the latest posts and updates.