Skip to content

Commit d150ac9

Browse files
committed
🚸 Flip the preview if the user is using a front camera
1 parent 2828a0e commit d150ac9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/src/widget/camera_picker.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,14 @@ class CameraPickerState extends State<CameraPicker>
12371237
}
12381238
final double _offsetHorizontal = (_width - constraints.maxWidth).abs() / -2;
12391239
final double _offsetVertical = (_height - constraints.maxHeight).abs() / -2;
1240+
// Flip the preview if the user is using a front camera to match the result.
1241+
if (currentCamera.lensDirection == CameraLensDirection.front) {
1242+
_preview = Transform(
1243+
transform: Matrix4.rotationY(math.pi),
1244+
alignment: Alignment.center,
1245+
child: _preview,
1246+
);
1247+
}
12401248
_preview = Stack(
12411249
children: <Widget>[
12421250
Positioned(

0 commit comments

Comments
 (0)