cast<S> method

  1. @override
StreamChannel<S> cast<S>()

Returns a copy of this with the generic type coerced to S.

If any events emitted by stream aren't of type S, they're converted into TypeError events (CastError on some SDK versions). Similarly, if any events are added to sink that aren't of type S, a TypeError is thrown.


StreamChannel<S> cast<S>() => StreamChannel(
    stream.cast(), StreamController(sync: true)<T>().pipe(sink));