copyWith method
Options
copyWith({
- String? method,
- int? sendTimeout,
- int? receiveTimeout,
- Map<
String, dynamic> ? extra, - Map<
String, dynamic> ? headers, - ResponseType? responseType,
- String? contentType,
- ValidateStatus? validateStatus,
- bool? receiveDataWhenStatusError,
- bool? followRedirects,
- int? maxRedirects,
- RequestEncoder? requestEncoder,
- ResponseDecoder? responseDecoder,
- ListFormat? listFormat,
Create a Option from current instance with merging attributes.
Implementation
Options copyWith({
String? method,
int? sendTimeout,
int? receiveTimeout,
Map<String, dynamic>? extra,
Map<String, dynamic>? headers,
ResponseType? responseType,
String? contentType,
ValidateStatus? validateStatus,
bool? receiveDataWhenStatusError,
bool? followRedirects,
int? maxRedirects,
RequestEncoder? requestEncoder,
ResponseDecoder? responseDecoder,
ListFormat? listFormat,
}) {
Map<String, dynamic>? _headers;
if (headers == null && this.headers != null) {
_headers = caseInsensitiveKeyMap(this.headers!);
}
if (headers != null) {
headers = caseInsensitiveKeyMap(headers);
assert(
!(contentType != null &&
headers.containsKey(Headers.contentTypeHeader)),
'You cannot set both contentType param and a content-type header',
);
}
Map<String, dynamic>? _extra;
if (extra == null && this.extra != null) {
_extra = Map.from(this.extra!);
}
return Options(
method: method ?? this.method,
sendTimeout: sendTimeout ?? this.sendTimeout,
receiveTimeout: receiveTimeout ?? this.receiveTimeout,
extra: extra ?? _extra,
headers: headers ?? _headers,
responseType: responseType ?? this.responseType,
contentType: contentType ?? this.contentType,
validateStatus: validateStatus ?? this.validateStatus,
receiveDataWhenStatusError:
receiveDataWhenStatusError ?? this.receiveDataWhenStatusError,
followRedirects: followRedirects ?? this.followRedirects,
maxRedirects: maxRedirects ?? this.maxRedirects,
requestEncoder: requestEncoder ?? this.requestEncoder,
responseDecoder: responseDecoder ?? this.responseDecoder,
listFormat: listFormat ?? this.listFormat,
);
}