patch method
Future<Response>
patch(
- String url, {
- String? token,
- dynamic data,
- Map? headers,
- String contentType = 'application/json',
- int msTimeout = 10000,
override
HTTP PATCH
Implementation
@override
Future<Response> patch(
String url, {
String? token,
dynamic data,
Map? headers,
String contentType = 'application/json',
int msTimeout = 10000,
}) async {
Map<String, dynamic> _headers = Map<String, dynamic>();
if (headers != null) {
headers.forEach((k, v) => _headers[k] = v);
}
if (token != null) _headers['Authorization'] = 'Bearer $token';
_headers['Content-Type'] = contentType;
_dio.options.connectTimeout = msTimeout;
_dio.options.receiveTimeout = msTimeout;
try {
final _response = await _dio.patch(
url,
data: data,
options: Options(headers: _headers),
);
return _returnResponse(_response);
} on DioError catch (e) {
if (e.type == DioErrorType.connectTimeout) {
throw TimeoutException(e.error);
} else if (e.type == DioErrorType.other) {
throw FetchDataException(e.error);
} else if (e.type == DioErrorType.response) {
return _returnResponse(e.response);
} else {
throw FetchDataException(e.error);
}
}
}