getRotation method
InputImageRotation
getRotation(
- CameraController cameraController
Returns the rotation of the camera for iOS and Android devices.
On iOS, the rotation is always 0 degrees (portrait). For Android, the sensor orientation is used to determine the correct rotation (90, 180, or 270 degrees).
Implementation
InputImageRotation getRotation(CameraController cameraController) {
if (Platform.isIOS) return InputImageRotation.rotation0deg;
final sensorOrientation = cameraController.description.sensorOrientation;
switch (sensorOrientation) {
case 90:
return InputImageRotation.rotation90deg;
case 180:
return InputImageRotation.rotation180deg;
case 270:
return InputImageRotation.rotation270deg;
default:
return InputImageRotation.rotation0deg;
}
}