patch method

Future<Response> patch({
  1. required String path,
  2. Map<String, dynamic>? queryParameters,
  3. Map<String, dynamic>? body,
  4. Map<String, dynamic>? headers,
  5. String contentType = 'application/json',
  6. void onSendProgress(
    1. int,
    2. int
    )?,
  7. void onReceiveProgress(
    1. int,
    2. int
    )?,
})

Implementation

Future<Response<dynamic>> patch({
  required String path,
  Map<String, dynamic>? queryParameters,
  Map<String, dynamic>? body,
  Map<String, dynamic>? headers,
  String contentType = 'application/json',
  void Function(int, int)? onSendProgress,
  void Function(int, int)? onReceiveProgress,
}) async {
  final requestBody = jsonEncode(body);

  //holds request options
  final options = headers!=null?Options(
    responseType: ResponseType.json,
    contentType: contentType,
    headers: headers
  ):Options(
    responseType: ResponseType.json,
    contentType: contentType,
  );

  debugPrint('================DioClientExtended Patch REQUEST================');
  debugPrint('REQUEST BODY: $body');
  try {
    final response = await dioClient.patch<dynamic>(
      path,
      queryParameters: queryParameters,
      options: options,
      data: requestBody,
      onSendProgress: onSendProgress,
      onReceiveProgress: onReceiveProgress,
    );

    debugPrint('================DioClientExtended Patch RESPONSE================');
    debugPrint('STATUS CODE: ${response.statusCode}');
    debugPrint('DATA: ${response.data}');
    return response;
  } on DioException catch (e) {
    debugPrint('DioException: $e');
    rethrow;
  }
}