toggleMute method

Future<bool> toggleMute({
  1. bool? unmute,
})

Implementation

Future<bool> toggleMute({bool? unmute}) async {
  var local = getLocalAttendee();

  var res = (unmute ?? local.muteStatus)
      ? await methodChannelProvider.callMethod(MethodCallOption.unmute)
      : await methodChannelProvider.callMethod(MethodCallOption.mute);
  if (res == null || !res.result) {
    debugPrint('Toggle mute failed');
    throw 'Failed to toggle your audio';
  }
  local.muteStatus = unmute ?? !local.muteStatus;
  _updateCurrentAttendee(local);
  return local.muteStatus;
}