deleteAttachment method

Future<void> deleteAttachment(
  1. String attachmentId
)

Implementation

Future<void> deleteAttachment(String attachmentId) async {
  bool success = await AttachmentService.deleteAttachment(attachmentId);
  if (success) {
    attachments.removeWhere(
      (Attachment attachment) => attachment.id == attachmentId,
    );
    filteredAttachments.removeWhere(
      (Attachment attachment) => attachment.id == attachmentId,
    );
    if (attachments.length < lengthToShowNoAttachments) {
      searchAttachments("");
      searchAttachmentsController.clear();
    }
    filteredAttachments.refresh();
    attachments.refresh();
    update();
  }
}