switchCamera method

Future<void> switchCamera()

Changes the state of the camera (front or back).

Does nothing if the device has no front camera.

Implementation

Future<void> switchCamera() async {
  await _methodChannel.invokeMethod('stop');
  final CameraFacing facingToUse =
      cameraFacingState.value == CameraFacing.back
          ? CameraFacing.front
          : CameraFacing.back;
  await start(cameraFacingOverride: facingToUse);
}