fromStream static method

Future<RestResponse> fromStream(
  1. StreamedResponse response, [
  2. JsonModelSerializer? serializer
])

Creates a new HTTP response by waiting for the full body to become available from a StreamedResponse.

Implementation

static Future<RestResponse> fromStream(
  StreamedResponse response, [
  JsonModelSerializer? serializer,
]) async {
  final body = await response.stream.toBytes();
  return RestResponse.bytes(
    body,
    serializer: serializer,
    response.statusCode,
    request: response.request,
    headers: response.headers,
    isRedirect: response.isRedirect,
    persistentConnection: response.persistentConnection,
    reasonPhrase: response.reasonPhrase,
  );
}