muteStateNotifier method

ValueNotifier<bool> muteStateNotifier(
  1. int targetIndex, {
  2. bool isLocally = false,
})

Is the current seat muted or not. Set isLocally to true to find out if it is muted locally.

Related APIs: muteLocally muteLocallyByUserID ZegoLiveAudioRoomControllerSeatHostImpl.mute ZegoLiveAudioRoomControllerSeatHostImpl.muteByUserID

example:

Display different icons according to the mute state change.

ValueListenableBuilder<bool>(
  valueListenable: ZegoUIKitPrebuiltLiveAudioRoomController()
      .seat
      .muteStateNotifier(
        ZegoUIKitPrebuiltLiveAudioRoomController()
            .seat
            .getSeatIndexByUserID($targetUserID),
      ),
  builder: (context, isMuted, _) {
    return Icon(isMuted ? Icons.volume_mute : Icons.volume_up);
  },
)

Implementation

ValueNotifier<bool> muteStateNotifier(
  int targetIndex, {
  bool isLocally = false,
}) {
  final targetUser = ZegoUIKit()
      .getUser(private.seatManager?.getUserByIndex(targetIndex)?.id ?? '');
  if (targetUser.isEmpty()) {
    return ValueNotifier<bool>(false);
  }

  return isLocally
      ? targetUser.microphoneMuteMode
      : private.microphoneMuteNotifier
          .getMicrophoneMuteStateNotifier(targetUser);
}