toggleCamera function

Future<void> toggleCamera({
  1. required SessionController sessionController,
})

Function to toggle enable/disable the camera

Implementation

Future<void> toggleCamera(
    {required SessionController sessionController}) async {
  var status = await Permission.camera.status;
  if (sessionController.value.isLocalVideoDisabled && status.isDenied) {
    await Permission.camera.request();
  }
  sessionController.value = sessionController.value.copyWith(
      isLocalVideoDisabled: !(sessionController.value.isLocalVideoDisabled));
  await sessionController.value.engine
      ?.muteLocalVideoStream(sessionController.value.isLocalVideoDisabled);
}