replace method

Response replace({
  1. List<int>? bodyBytes,
  2. String? bodyString,
  3. int? status,
  4. String? statusText,
  5. Map<String, String>? headers,
})

Create a new Response using all the values from this instance except for the parameters specified.

Implementation

Response replace(
    {List<int>? bodyBytes,
    String? bodyString,
    int? status,
    String? statusText,
    Map<String, String>? headers}) {
  status = status ?? this.status;
  statusText = statusText ?? this.statusText;
  headers = headers ?? this.headers;
  if (bodyBytes == null) {
    if (bodyString == null) {
      return Response._(status, statusText, headers, _body);
    } else {
      return Response.fromString(status, statusText, headers, bodyString);
    }
  } else {
    return Response.fromBytes(status, statusText, headers, bodyBytes);
  }
}