From d150ac956253960b1d90feac69ffeb5ca9b4f610 Mon Sep 17 00:00:00 2001 From: Alex Li Date: Thu, 16 Sep 2021 11:11:15 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Flip=20the=20preview=20if=20the?= =?UTF-8?q?=20user=20is=20using=20a=20front=20camera?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/src/widget/camera_picker.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/src/widget/camera_picker.dart b/lib/src/widget/camera_picker.dart index fe0c210..7e5fc27 100644 --- a/lib/src/widget/camera_picker.dart +++ b/lib/src/widget/camera_picker.dart @@ -1237,6 +1237,14 @@ class CameraPickerState extends State } final double _offsetHorizontal = (_width - constraints.maxWidth).abs() / -2; final double _offsetVertical = (_height - constraints.maxHeight).abs() / -2; + // Flip the preview if the user is using a front camera to match the result. + if (currentCamera.lensDirection == CameraLensDirection.front) { + _preview = Transform( + transform: Matrix4.rotationY(math.pi), + alignment: Alignment.center, + child: _preview, + ); + } _preview = Stack( children: [ Positioned(