addStream method

  1. @override
Future<void> addStream(
  1. Stream<List<int>> stream
)
override

Adds a stream of byte chunks to the request body.

Each chunk is forwarded to the internal stream controller and the underlying request.

Implementation

@override
Future<void> addStream(Stream<List<int>> stream) {
  // Broadcast the incoming stream so multiple listeners can subscribe.
  final newStream = stream.asBroadcastStream();

  // Listen and add each chunk to the internal stream controller.
  newStream.listen((chunk) => _streamController.add(chunk));

  // Forward the stream to the actual request.
  return request.addStream(newStream);
}