delete method

Future<void> delete()

Deletes the document referred to by this DocumentReference.

Implementation

Future<void> delete() async {
  // if we don't have the document ID, get it first.
  if (id == null) _id = (await get())?.id;
  if (_id == null) return; // early out if this document does not exist

  final response = await service._delete(documentUri);
  int httpStatusCode = response.statusCode;

  if (httpStatusCode == HttpStatus.ok) {
    return;
  } else {
    final Map<String, dynamic> responseJson =
        json.decode(response.body) as Map<String, dynamic>;
    throw CarpServiceException.fromMap(httpStatusCode, responseJson);
  }
}