getUndeliveredMembers method Null safety

List<Member> getUndeliveredMembers(
  1. BaseMessage message
)

Returns undelivered member count as int with given message.

Implementation

List<Member> getUndeliveredMembers(BaseMessage message) {
  if (message is AdminMessage) return [];
  if (isSuper) return [];
  // if (_sdk.state.currentUser == null) return []; //check connection

  final deliveryStatus =
      _sdk.cache.find<DeliveryStatus>(channelKey: channelUrl);

  // delivery receipt feature is not on, throw?
  if (deliveryStatus == null) return [];

  return members.where((m) {
    if (m.isCurrentUser) return false;
    if (message.sender?.userId == m.userId) return false;
    if (m.state != MemberState.joined) return false;
    final deliveredAt = deliveryStatus.updatedDeliveryReceipt[m.userId] ?? 0;
    return deliveredAt < message.createdAt;
  }).toList();
}