Screen orientation in flutter on android devices works wrong

Viewed 356

In my flutter app I need a two screen orientation types. Some screens must be a portrait up and some screens must be portrait up and landscape left. So, in build method I use SystemChrome.setPreferredOrientations. If I set

SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeLeft,
      DeviceOrientation.portraitUp,
      DeviceOrientation.landscapeRight, ]);

that's ok. But if I set only two orientations

SystemChrome.setPreferredOrientations([
      DeviceOrientation.landscapeLeft,
      DeviceOrientation.portraitUp, ]);

that's ok on iPhone devices, but on android device screen opens with first orientation from list only and doesn't rotate to the second one. So in this case it always will be landscapeLeft regardless of the phone position and will not rotate to portrait.

1 Answers

I think you have to use only one type of DeviceOrientation, whether it is Landscape, or Portrait. You cannot set both of the types at once. You can only set whether it is DeviceOrientation.landscapeLeft, and DeviceOrientation.landscapeRight. Or DeviceOrientation.portraitUp only.

Related