copyWith method

ApiRequest<ResponseType, InnerType> copyWith({
  1. String? method,
  2. String? path,
  3. String? dataKey,
  4. String? paginationKey,
  5. String? baseUrl,
  6. bool? hasPagination,
  7. RetryPolicy? retryPolicy,
  8. int? timeout,
  9. bool? override500Error,
  10. bool? isMultipart,
  11. Object? body = _unset,
  12. Map<String, String>? headers,
  13. List<ApiInterceptor>? interceptors,
  14. Object? error = _unset,
  15. Object? nestedKey = _unset,
  16. Map<String, dynamic>? query,
})

Note: interceptors are appended to the existing chain rather than replacing it, so an interceptor can add another without discarding the ones already configured on the request.

Implementation

ApiRequest<ResponseType, InnerType> copyWith({
  String? method,
  String? path,
  String? dataKey,
  String? paginationKey,
  String? baseUrl,
  bool? hasPagination,
  RetryPolicy? retryPolicy,
  int? timeout,
  bool? override500Error,
  bool? isMultipart,
  Object? body = _unset,
  Map<String, String>? headers,
  List<ApiInterceptor>? interceptors,
  Object? error = _unset,
  Object? nestedKey = _unset,
  Map<String, dynamic>? query,
}) => ApiRequest<ResponseType, InnerType>(
  requestId: requestId,
  hasPagination: hasPagination ?? this.hasPagination,
  headers: headers ?? this.headers,
  query: query ?? this.query,
  method: method ?? this.method,
  dataKey: dataKey ?? this.dataKey,
  paginationKey: paginationKey ?? this.paginationKey,
  // ignore: deprecated_member_use_from_same_package
  nestedKey: identical(nestedKey, _unset)
      ? this.nestedKey
      : nestedKey as String?,
  isMultipart: isMultipart ?? this.isMultipart,
  path: path ?? this.path,
  retryPolicy: retryPolicy ?? this.retryPolicy,
  error: identical(error, _unset) ? this.error : error as ErrorDescription?,
  timeout: timeout ?? this.timeout,
  override500Error: override500Error ?? this.override500Error,
  baseUrl: baseUrl ?? this.baseUrl,
  interceptors: [...?interceptors, ...this.interceptors],
  body: identical(body, _unset) ? this.body : _asBody(body),
);