updateUserAudio method

void updateUserAudio({
  1. required int uid,
  2. required bool muted,
})

Implementation

void updateUserAudio({required int uid, required bool muted}) {
  // if local user updates audio
  if (uid == value.localUid) {
    value = value.copyWith(isLocalUserMuted: muted);
    // if remote user updates audio
  } else if (uid == value.mainAgoraUser.uid) {
    value = value.copyWith(mainAgoraUser: AgoraUser(uid: uid, muted: muted));
  } else {
    List<AgoraUser> tempList = value.users;
    int indexOfUser = tempList.indexWhere((element) => element.uid == uid);
    if (indexOfUser == -1) return; //this means user is no longer in the call
    tempList[indexOfUser] = tempList[indexOfUser].copyWith(muted: muted);
    value = value.copyWith(users: tempList);
  }
}