stream<T> static method

Stream<T> stream<T>()

转为 Stream

Implementation

static Stream<T> stream<T>() {
  final controller = StreamController<T>.broadcast();
  void listener(T event) => controller.add(event);
  on<T>(listener);
  controller.onCancel = () => off<T>(listener);
  return controller.stream;
}