Flutter camera plugin: how do I lockCaptureOrientation on either landscapeRight or landscapeLeft?

Viewed 22

I am writing a landscape flutter application that uses the camera plugin.

To make my app landscape, I have the following lines in my main:

  WidgetsFlutterBinding.ensureInitialized();
  await SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeRight, DeviceOrientation.landscapeLeft]);

This does not prevent from receiving a landscape image from the camera stream so, after initializing the camera controller, I have the line

_controller?.lockCaptureOrientation(DeviceOrientation.landscapeRight);

With this line, the camera gives only landscape images, but now the app will not work properly in landscapeLeft. Is there a way to enforce the capture orientation to be either landscapeRight or landscapeLeft?

0 Answers
Related