fromHttpResponse static method

ApiCallResponse fromHttpResponse(
  1. Response response,
  2. bool returnBody,
  3. bool decodeUtf8
)

Implementation

static ApiCallResponse fromHttpResponse(
  http.Response response,
  bool returnBody,
  bool decodeUtf8,
) {
  var jsonBody;
  try {
    final responseBody = decodeUtf8 && returnBody
        ? const Utf8Decoder().convert(response.bodyBytes)
        : response.body;
    jsonBody = returnBody ? json.decode(responseBody) : null;
  } catch (_) {}
  return ApiCallResponse(
    jsonBody,
    response.headers,
    response.statusCode,
    response: response,
  );
}