Movatterモバイル変換


[0]ホーム

URL:


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

toSet method

Future<Set<T>>toSet()

Collects the data of this stream in aSet.

Creates aSet<T> and adds all elements of this stream to the set.in the order they arrive.When this stream ends, the returned future is completed with that set.

The returned set is the same type as created by<T>{}.If another type of set is needed, either useforEach to add eachelement to the set, or usetoList().then((list) => new SomeOtherSet.from(list))to create the set.

If this stream emits an error,the returned future is completed with that error,and processing stops.

Implementation

Future<Set<T>> toSet() {  Set<T> result = Set<T>();  _Future<Set<T>> future = _Future<Set<T>>();  this.listen(    (T data) {      result.add(data);    },    onError: future._completeError,    onDone: () {      future._complete(result);    },    cancelOnError: true,  );  return future;}
  1. Dart
  2. dart:async
  3. Stream<T>
  4. toSet method
Stream class

[8]ページ先頭

©2009-2025 Movatter.jp