delete<T extends ParseObject> method

Future<ParseResponse> delete<T extends ParseObject>({
  1. String? id,
  2. String? path,
})

Deletes the current object locally and online

Implementation

Future<ParseResponse> delete<T extends ParseObject>({
  String? id,
  String? path,
}) async {
  assert(() {
    final objId = objectId;
    final isNotValidObjectId = objId == null || objId.isEmpty;
    final isNotValidIdArg = id == null || id.isEmpty;

    if (isNotValidObjectId && isNotValidIdArg) {
      throw Exception(
        "Can't delete a parse object while the objectId property "
        "and id argument is null or empty",
      );
    }

    return true;
  }());

  try {
    path ??= _path;
    id ??= objectId;
    final Uri url = getSanitisedUri(_client, '$_path/$id');
    final ParseNetworkResponse result = await _client.delete(url.toString());
    return handleResponse<T>(
        this, result, ParseApiRQ.delete, _debug, parseClassName);
  } on Exception catch (e) {
    return handleException(e, ParseApiRQ.delete, _debug, parseClassName);
  }
}