Skip to content

Commit

Permalink
🚸 Flip the preview if the user is using a front camera
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 committed Sep 16, 2021
1 parent 2828a0e commit d150ac9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/src/widget/camera_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,14 @@ class CameraPickerState extends State<CameraPicker>
}
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: <Widget>[
Positioned(
Expand Down

0 comments on commit d150ac9

Please sign in to comment.