deliveryStream method Null safety

Stream<Map<String, int>> deliveryStream(
  1. {String? channelUrl}
)

Returns a stream to listen delivery event with given channelUrl

It will be triggered every delivery event if channelUrl is not provided

Implementation

Stream<Map<String, int>> deliveryStream({String? channelUrl}) async* {
  if (currentUser == null) throw ConnectionRequiredError();

  await for (final res in _int.streamManager.delivery.stream) {
    if (channelUrl != null) {
      if (res.channelUrl == channelUrl) {
        final status =
            _int.cache.find<DeliveryStatus>(channelKey: channelUrl);
        if (status != null) yield status.updatedDeliveryReceipt;
      }
    } else {
      final status =
          _int.cache.find<DeliveryStatus>(channelKey: res.channelUrl);
      if (status != null) yield status.updatedDeliveryReceipt;
    }
  }
}