transformStream<T, E> function

Stream<E> transformStream<T, E>(
  1. Stream<T> rawStream,
  2. StreamTransformer<T, E> builder
)

Byte stream builder Use DataReader to handle byte data, and transform to specified type data For example:

Stream

void main() { transformStream(testStream(), (streamReader) { return streamReader.read(); }).listen(print); }

Output:

0 0 1 0

Implementation

Stream<E> transformStream<T, E>(Stream<T> rawStream, StreamTransformer<T, E> builder) async* {
	final reader = StreamReader<T>(rawStream);
	while (!reader.isEnd) {
		final transformedData = await builder(reader);
		yield transformedData;
	}
}