Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter camera plugin prevent orientation change?

Using the latest version 0.8.1, is there a way to prevent orientation change? I have locked the device orientation using SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); but if I rotate the device to landscape, the camera also attempts to rotate and the preview looks compressed. A good example would be the instagram camera, which is locked to portrait mode. If you rotate your device the preview doesn't move at all.

like image 564
user1087973 Avatar asked Aug 13 '26 00:08

user1087973


1 Answers

You can apply lock on capture orientation this will also used for app being crashed during camera initialisation

await _cameraController.initialize();
await _cameraController.lockCaptureOrientation();
like image 69
Nandakishor Dhanaji Valakunde Avatar answered Aug 14 '26 16:08

Nandakishor Dhanaji Valakunde



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!