Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions packages/camera/camera_android_camerax/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,29 @@
## 0.6.18+3

* Fixes incorrect camera preview mirroring for front cameras of devices using the Impeller backend.

## 0.6.18+2

* Fixes premature garbage collection of native objects when app is under memory pressure.

## 0.6.18+1

* Makes Java style improvements.

## 0.6.18

* Adds support for the `MediaSettings.enableAudio` setting, which determines whether or not audio is
recorded during video recording.

## 0.6.17+1

* Replaces deprecated `onSurfaceDestroyed` with `onSurfaceCleanup`.

## 0.6.17

* Fixes incorrect camera preview mirroring for front cameras of devices using the `ImageReader`
Impeller backend.
* Replaces `BroadcastReceiver` usage with an `OrientationEventListener` to detect changes in device
orientation to fix issue where some devices do not report changes in device configuration if it
is rotated between the same sort of orientation (landscape/portrait).

## 0.6.16

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,32 +157,27 @@ final class _ImageReaderRotatedPreviewState
sign: widget.facingSign,
);

// If the camera is front facing (widget.facingSign is 1 for front
// cameras, -1 for back cameras), mirror the camera preview
// according to the current device orientation.
Widget cameraPreview = widget.child;
if (widget.facingSign == 1) {
if (deviceOrientation == DeviceOrientation.portraitDown ||
deviceOrientation == DeviceOrientation.portraitUp) {
cameraPreview = Transform.scale(
scaleY: -1,
child: cameraPreview,
);
} else {
cameraPreview = Transform.scale(
scaleX: -1,
child: cameraPreview,
);
}
// If the camera is front facing (widget.facingSign is 1 for front
// cameras, -1 for back cameras), mirror the camera preview
// according to the current device orientation.
Widget cameraPreview = widget.child;
if (widget.facingSign == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is == 1 the correct comparison here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah because facingSign maps to the sign in https://developer.android.com/media/camera/camera2/camera-preview#orientation_calculation, which is 1 for front cameras, -1 for back facing cameras. I'll add a comment to the code!

if (deviceOrientation == DeviceOrientation.portraitDown ||
deviceOrientation == DeviceOrientation.portraitUp) {
cameraPreview = Transform.scale(scaleY: -1, child: cameraPreview);
} else {
cameraPreview = Transform.scale(scaleX: -1, child: cameraPreview);
}

return RotatedBox(
quarterTurns: rotationDegrees ~/ 90,
child: cameraPreview,
);
} else {
return const SizedBox.shrink();
}
});

return RotatedBox(
quarterTurns: rotationDegrees ~/ 90,
child: cameraPreview,
);
} else {
return const SizedBox.shrink();
}
},
);
}
}
2 changes: 1 addition & 1 deletion packages/camera/camera_android_camerax/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_android_camerax
description: Android implementation of the camera plugin using the CameraX library.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.6.17
version: 0.6.18+3

environment:
sdk: ^3.7.0
Expand Down
Loading