Skip to content

Commit 680cb2d

Browse files
committed
🚑️ Fix scaling issues with turns and orientations
Fix #77, #69
1 parent 8fb5430 commit 680cb2d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/src/widgets/camera_picker.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,13 @@ class CameraPickerState extends State<CameraPicker>
488488
BoxConstraints constraints,
489489
CameraController controller,
490490
) {
491+
final int turns = widget.cameraQuarterTurns;
492+
final String orientation = controller.value.deviceOrientation.toString();
491493
// Fetch the biggest size from the constraints.
492494
Size size = constraints.biggest;
493495
// Flip the size when the preview needs to turn with an odd count of quarters.
494-
if (widget.cameraQuarterTurns % 2 != 0) {
496+
if ((turns.isOdd && orientation.contains('portrait')) ||
497+
(turns.isEven && orientation.contains('landscape'))) {
495498
size = size.flipped;
496499
}
497500
// Calculate scale depending on the size and camera ratios.

0 commit comments

Comments
 (0)