Movatterモバイル変換


[0]ホーム

URL:


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

drain<E> method

Future<E>drain<E>([
  1. E?futureValue
])

Discards all data on this stream, but signals when it is done or an erroroccurred.

When subscribing usingdrain, cancelOnError will be true. This meansthat the future will complete with the first error on this stream and thencancel the subscription.

If this stream emits an error, the returned future is completed withthat error, and processing is stopped.

In case of adone event the future completes with the givenfutureValue.

ThefutureValue must not be omitted ifnull is not assignable toE.

Example:

final result = await Stream.fromIterable([1, 2, 3]).drain(100);print(result); // Outputs: 100.

Implementation

Future<E> drain<E>([E? futureValue]) {  if (futureValue == null) {    futureValue = futureValue as E;  }  return listen(null, cancelOnError: true).asFuture<E>(futureValue);}
  1. Dart
  2. dart:async
  3. Stream<T>
  4. drain<E> method
Stream class

[8]ページ先頭

©2009-2025 Movatter.jp