StreamedHttpBody.fromByteStream constructor

StreamedHttpBody.fromByteStream(
  1. MediaType? contentType,
  2. Stream<List<int>> byteStream, {
  3. int? contentLength,
  4. Encoding? fallbackEncoding,
})

Construct the body to an HTTP request or an HTTP response from a stream of chunks of bytes. The given byteStream should be a single- subscription stream.

Implementation

factory StreamedHttpBody.fromByteStream(
    MediaType? contentType, Stream<List<int>> byteStream,
    {int? contentLength, Encoding? fallbackEncoding}) {
  final nonNullFallbackEncoding =
      fallbackEncoding ?? utf8; // Use UTF-8 as the default fallback encoding.
  return StreamedHttpBody._(
      contentType, byteStream, contentLength, nonNullFallbackEncoding);
}