toggleMute function

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

Function to mute/unmute the microphone

Implementation

Future<void> toggleMute({required SessionController sessionController}) async {
  var status = await Permission.microphone.status;
  if (sessionController.value.isLocalUserMuted && status.isDenied) {
    await Permission.microphone.request();
  }
  sessionController.value = sessionController.value
      .copyWith(isLocalUserMuted: !(sessionController.value.isLocalUserMuted));
  await sessionController.value.engine
      ?.muteLocalAudioStream(sessionController.value.isLocalUserMuted);
}