deleteData static method

Future deleteData({
  1. required String url,
  2. Map<String, String> header = const {'Content-Type' : 'application/json'},
})

Implementation

static Future<dynamic> deleteData({
  required String url,
  Map<String, String> header = const {'Content-Type': 'application/json'},
}) async {
  try {
    Response response = await delete(
      Uri.parse(url),
      headers: header,
    );
    log('POST status: ${response.statusCode}');
    if (response.statusCode == 200) {
      if (response.body.isNotEmpty) {
        return jsonDecode(response.body);
      }
      return null;
    }
    throw ApiFailedException(msg: 'failed to delete :(');
  } on ApiFailedException catch (e) {
    log(e.toString());
    return null;
  }
}