Device Orientation does not work properly
mrietunjoy opened this issue · 2 comments
Hi, while you are setting the device orientation, the orientation is set as per only the first item in the array which is sent as a argument of setPreferredOrientations in main.dart. Line 10.
await SystemChrome.setPreferredOrientations(<DeviceOrientation>[
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown
]).then((_) => runApp(MyApp()));
I tried running it in a virtual device as well as a Mobile device. But if the first item is changed only then it comes to effect.
This occured when I set the first item in the list to DeviceOrientation.landscapeLeft
Desktop (please complete the following information):
- OS: Windows 10
- Browser: Chrome
Smartphone (please complete the following information):
- Device: Pixcel 3A(Virtual Device), Redmi 9A, Nokia 6.1 plus
- OS: Android
Thanks
So, currently I think it is respected in iPad. I have shared a link below which shows the limitation, of this approach.
https://api.flutter.dev/flutter/services/SystemChrome/setPreferredOrientations.html
And if anyone is checking for this issue. The above code will work for one particular Orientation like PortraitUp or PortraitDown which ever is placed in the array first.
But if you want to assign a Orientation then there is no need for the above code. For more details on DeviceOrientation you can check, the docs: https://api.flutter.dev/flutter/services/DeviceOrientation-class.html