stream static method

Response stream(
  1. void fn(
    1. StreamSink<List<int>>
    ), {
  2. int status = 200,
  3. Headers? headers,
})

Implementation

static Response stream(void Function(StreamSink<List<int>>) fn,
    {int status = 200, Headers? headers}) {
  final controller = StreamController<List<int>>();
  scheduleMicrotask(() => fn(controller.sink));
  return Response(status,
      headers: headers ?? Headers(), body: controller.stream, isStream: true);
}