copyWith method

Request<T> copyWith({
  1. Uri? url,
  2. String? method,
  3. Map<String, String>? headers,
  4. Stream<List<int>>? bodyBytes,
  5. bool? followRedirects,
  6. int? maxRedirects,
  7. int? contentLength,
  8. FormData? files,
  9. bool? persistentConnection,
  10. Decoder<T>? decoder,
  11. bool appendHeader = true,
  12. ResponseInterceptor<T>? responseInterceptor,
})

Implementation

Request<T> copyWith({
  Uri? url,
  String? method,
  Map<String, String>? headers,
  Stream<List<int>>? bodyBytes,
  bool? followRedirects,
  int? maxRedirects,
  int? contentLength,
  FormData? files,
  bool? persistentConnection,
  Decoder<T>? decoder,
  bool appendHeader = true,
  ResponseInterceptor<T>? responseInterceptor,
}) {
  // If appendHeader is set to true, we will merge origin headers with that
  if (appendHeader && headers != null) {
    headers.addAll(this.headers);
  }

  return Request<T>._(
      url: url ?? this.url,
      method: method ?? this.method,
      bodyBytes: bodyBytes ?? this.bodyBytes,
      headers: headers == null ? this.headers : Map.from(headers),
      followRedirects: followRedirects ?? this.followRedirects,
      maxRedirects: maxRedirects ?? this.maxRedirects,
      contentLength: contentLength ?? this.contentLength,
      files: files ?? this.files,
      persistentConnection: persistentConnection ?? this.persistentConnection,
      decoder: decoder ?? this.decoder,
      responseInterceptor: responseInterceptor ?? this.responseInterceptor);
}