rmtmckenzie / flutter_native_device_orientation

Native device orientation plugin for flutter.
MIT License
76 stars 63 forks source link

Landscape left not working as expected #36

Closed ervindobri closed 2 years ago

ervindobri commented 2 years ago

I'm trying to build an app which is landscape only oriented, and a weird issue appeared. When in LandscapeLeft the orientation built is sometimes LandscapeLeft, sometimes PortraitUp; Device: iPhone 12 mini.

Sample code:

return NativeDeviceOrientationReader(
        useSensor: true,
        builder: (context) {
          final orientation =
              NativeDeviceOrientationReader.orientation(context);
          print(orientation);
          return SomeWidget();
});

Output: flutter: NativeDeviceOrientation.landscapeLeft flutter: NativeDeviceOrientation.portraitUp

rmtmckenzie commented 2 years ago

This is because when the device returns an unknown orientation, it defaults to portrait up. You can now change this by setting "defaultOrientation" to "NativeDeviceOrientation.landscapeLeft"