close method

  1. @override
Future close()
override

Closes the stream.

No further events can be added to a closed stream.

The returned future is the same future provided by done. It is completed when the stream listeners is done sending events, This happens either when the done event has been sent, or when the subscriber on a single-subscription stream is canceled.

A broadcast stream controller will send the done event even if listeners are paused, so some broadcast events may not have been received yet when the returned future completes.

If no one listens to a non-broadcast stream, or the listener pauses and never resumes, the done event will not be sent and this future will never complete.

Implementation

@override
Future<dynamic> close() {
  if (_isAddingStreamItems) {
    throw StateError(
        'You cannot close the subject while items are being added from addStream');
  }

  return _controller.close();
}