CopyStream static method

Future<void> CopyStream(
  1. Stream<List<int>> source,
  2. StreamConsumer<List<int>> target
)
Copies source stream to target. The source. The target.

Implementation

static Future<void> CopyStream(
    Stream<List<int>> source, StreamConsumer<List<int>> target) async {
  await source.pipe(target);
//            // See if this is a MemoryStream -- we can use WriteTo.
//            MemoryStream memContentStream = source as MemoryStream;
//            if (memContentStream != null)
//            {
//                memContentStream.WriteTo(target);
//            }
//            else
//            {
//                // Otherwise, copy data through a buffer
//                Uint8List buffer = new byte[4096];
//                int bufferSize = buffer.Length;
//                int bytesRead = source.Read(buffer, 0, bufferSize);
//                while (bytesRead > 0)
//                {
//                    target.Write(buffer, 0, bytesRead);
//                    bytesRead = source.Read(buffer, 0, bufferSize);
//                }
//            }
}