onNotificationRemovedFromChannel method

void onNotificationRemovedFromChannel(
  1. Event event,
  2. StreamChannelListController controller
)

Function which gets called for the event EventType.notificationRemovedFromChannel.

This event is fired when a user is removed from a channel which we are not currently watching.

By default, this removes the event channel from the list.

Implementation

void onNotificationRemovedFromChannel(
  Event event,
  StreamChannelListController controller,
) {
  final channels = [...controller.currentItems];
  final updatedChannels =
      channels.where((it) => it.cid != event.channel?.cid);
  final listChanged = channels.length != updatedChannels.length;

  if (!listChanged) return;

  controller.channels = [...updatedChannels];
}