take method

Stream<T> take(int count)

Provides at most the first count data events of this stream.

Forwards all events of this stream to the returned stream until count data events have been forwarded or this stream ends, then ends the returned stream with a done event.

If this stream produces fewer than count data events before it's done, so will the returned stream.

Starts listening to this stream when the returned stream is listened to and stops listening when the first count data events have been received.

This means that if this is a single-subscription (non-broadcast) streams it cannot be reused after the returned stream has been listened to.

If this is a broadcast stream, the returned stream is a broadcast stream. In that case, the events are only counted from the time the returned stream is listened to.

Source

Stream<T> take(int count) {
  return new _TakeStream<T>(this, count);
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-async/Stream/take.html