delete method

Future<Response> delete(
  1. String url, {
  2. Map<String, String>? headers,
})

Sends an HTTP DELETE request with the given headers to the given url.

Implementation

Future<http.Response> delete(
  String url, {
  Map<String, String>? headers,
}) async {
  // calling the http DELETE method using the retry approach
  final http.Response response = await retry(
    () => client
        .delete(
          Uri.parse(Uri.encodeFull(url)),
          headers: headers,
        )
        .timeout(const Duration(seconds: 15)),
    delayFactor: const Duration(seconds: 5),
    maxAttempts: 15,
    retryIf: (e) => e is SocketException || e is TimeoutException,
    onRetry: (e) => print('${e.runtimeType} - Retrying to DELETE $url'),
  );
  return response;
}