allSent property

Future get allSent

Returns a future which is completed when the sink sent all added data, instead of only if the sink got closed.

Might fail with an error in case if something occurred while sending the data. Typical error could be StateError("Not connected!") which could happen if disconnected in middle of sending (queued) data.

Implementation

Future get allSent => Future(() async {
      // Simple `await` can't get job done here, because the `_chainedFutures` member
      // in one access time provides last Future, then `await`ing for it allows the library
      // user to add more futures on top of the waited-out Future.
      Future lastFuture;
      do {
        lastFuture = _chainedFutures;
        await lastFuture;
      } while (lastFuture != _chainedFutures);

      _chainedFutures = Future.value();
    });