DeferStream<T> constructor

DeferStream<T>(
  1. Stream<T> streamFactory(), {
  2. bool reusable = false,
})

Constructs a Stream lazily, at the moment of subscription, using the streamFactory

Implementation

DeferStream(Stream<T> Function() streamFactory, {bool reusable = false})
    : _isReusable = reusable,
      _factory = reusable
          ? streamFactory
          : (() {
              Stream<T>? stream;
              return () => stream ??= streamFactory();
            }());