How to set Device orientation for flutter web?

Viewed 95

We can set device orientation for flutter apps by using SystemChrome.setPreferredOrientations([.....]) . But this doesn't work in case of flutter web. so how to set the device orientation in flutter web apps.

1 Answers

After reseach I found that the most effective way to handle the issue is to use
RotatedBox https://api.flutter.dev/flutter/widgets/RotatedBox-class.html

You should use it with MediaQuery.of(context).orientation to check whether the rotation is needed.
Use RotatedBox on highest level in build method:

Widget build(BuildContext context) {
    return RotatedBox(...);
}
Related