Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force flutter `camera` plugin to take photo in portrait mode?

Is there a general way to do this?

To add more context, it seems the camera plugin takes into account the device orientation when capturing image from the camera. Can we control it so that no matter what the orientation is, the result is still the same?

plugin: camera 0.4.0+3

like image 419
Willy Avatar asked Mar 05 '19 04:03

Willy


People also ask

How do you turn on portrait mode on flutter?

To app-wide change/lock device orientation to portrait/landscape only in Flutter, you can use the SystemChrome. setPreferredOrientations method and allow the list of orientations that you want to set.

How do you take a picture with a camera flutter?

You can use the takePicture() method on the camera controller to take a picture using the device camera. The captured picture is returned as a XFile (which is a cross-platform file abstraction). This function returns the captured picture as XFile if the capture is successful, otherwise it returns null .


1 Answers

For those who're struggling with this problem, checking your device orientation when taking photos and its resulting exif data should help. Try these libraries:

native_device_orientation

exif

flutter_exif_rotation

like image 108
Willy Avatar answered Nov 13 '22 08:11

Willy