patchRequest method

Future patchRequest(
  1. String endUrl,
  2. dynamic body, {
  3. String? contentType,
  4. Decoder? decoder,
  5. Map<String, String>? headers,
  6. Map<String, dynamic>? query,
  7. Progress? uploadProgress,
})

API Patch Method

Implementation

Future<dynamic> patchRequest(
  String endUrl,
  dynamic body, {
  String? contentType,
  Decoder? decoder,
  Map<String, String>? headers,
  Map<String, dynamic>? query,
  Progress? uploadProgress,
}) async {
  _debugLog('PATCH Request - URL: $endUrl');
  _debugLog('PATCH Body: $body');

  final connectivityResult = await (Connectivity().checkConnectivity());
  if (connectivityResult.length <= 1 &&
      connectivityResult.first == ConnectivityResult.none) {
    _debugLog('No internet connection detected', isError: true);
    throw _handleInternetError();
  }
  try {
    headers ?? _headers;

    _debugLog('Sending PATCH request to: $_baseUrl$endUrl');
    final response = await patch(endUrl, body,
        contentType: contentType,
        decoder: decoder,
        headers: headers,
        query: query,
        uploadProgress: uploadProgress);
    _debugLog('PATCH Response - Status: ${response.statusCode}');
    return processAndHandleResponse(response);
  } on GetHttpException catch (ex) {
    _debugLog('PATCH GetHttpException: ${ex.message}', isError: true);
    throw _handleError(ex);
  } on UnauthorizedException catch (ex) {
    _debugLog('PATCH UnauthorizedException: $ex', isError: true);
    throw _handleError(ex);
  } on UnexpectedFormat catch (ex) {
    _debugLog('PATCH UnexpectedFormat: ${ex.message}', isError: true);
    throw _handleError(ex);
  } on Exception catch (ex) {
    _debugLog('PATCH Exception: $ex', isError: true);
    throw _handleError(ex);
  } on FlutterErrorDetails catch (ex) {
    _debugLog('PATCH FlutterErrorDetails: ${ex.exceptionAsString()}',
        isError: true);
    throw _handleError(ex);
  }
}