deleteRequest method
API Delete Method
Implementation
Future<dynamic> deleteRequest(
String endUrl, {
Map<String, String>? headers,
String? contentType,
Decoder? decoder,
Map<String, dynamic>? query,
}) async {
_debugLog('DELETE Request - URL: $endUrl');
_debugLog('Query Parameters: $query');
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 DELETE request to: $_baseUrl$endUrl');
final response = await delete(endUrl,
headers: headers,
contentType: contentType,
decoder: decoder,
query: query);
_debugLog('DELETE Response - Status: ${response.statusCode}');
return processAndHandleResponse(response);
} on GetHttpException catch (ex) {
_debugLog('DELETE GetHttpException: ${ex.message}', isError: true);
throw _handleError(ex);
} on UnauthorizedException catch (ex) {
_debugLog('DELETE UnauthorizedException: $ex', isError: true);
throw _handleError(ex);
} on UnexpectedFormat catch (ex) {
_debugLog('DELETE UnexpectedFormat: ${ex.message}', isError: true);
throw _handleError(ex);
} on Exception catch (ex) {
_debugLog('DELETE Exception: $ex', isError: true);
throw _handleError(ex);
} on FlutterErrorDetails catch (ex) {
_debugLog('DELETE FlutterErrorDetails: ${ex.exceptionAsString()}',
isError: true);
throw _handleError(ex);
}
}