Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:async
  3. Stream<T>
  4. where method
where
description

where method

Stream<T>where(
  1. booltest(
    1. Tevent
    )
)

Creates a new stream from this stream that discards some elements.

The new stream sends the same error and done events as this stream,but it only sends the data events that satisfy thetest.

If thetest function throws, the data event is dropped and theerror is emitted on the returned stream instead.

The returned stream is a broadcast stream if this stream is.If a broadcast stream is listened to more than once, each subscriptionwill individually perform thetest.

Example:

final stream =    Stream<int>.periodic(const Duration(seconds: 1), (count) => count)        .take(10);final customStream = stream.where((event) => event > 3 && event <= 6);customStream.listen(print); // Outputs event values: 4,5,6.

Implementation

Stream<T> where(bool test(T event)) {  return _WhereStream<T>(this, test);}
  1. Dart
  2. dart:async
  3. Stream<T>
  4. where method
Stream class

[8]ページ先頭

©2009-2025 Movatter.jp