ByteStream.fromBroadcast constructor

ByteStream.fromBroadcast(
  1. List<int> bytes
)

Creates a ByteStream from a list of bytes that can be broadcasted.

bytes the byte data

A stream of bytes similar to Java's InputStream/OutputStream.

This class provides a stream-based interface for reading and writing bytes, wrapping Dart's Stream<List<int>> with Java-like methods.

Example usage:

ByteStream stream = ByteStream.fromList([72, 101, 108, 108, 111]);
List<int> data = await stream.readAll();
print(String.fromCharCodes(data)); // "Hello"

Implementation

factory ByteStream.fromBroadcast(List<int> bytes) {
  return ByteStream._(Stream.value(bytes).asBroadcastStream());
}