openAttachmentNoteModal method

Future<void> openAttachmentNoteModal(
  1. Attachment? attachment, {
  2. bool isEditable = true,
})

Implementation

Future<void> openAttachmentNoteModal(
  Attachment? attachment, {
  bool isEditable = true,
}) async {
  noteName.value = attachment?.fileName ?? "";
  if (attachment != null) {
    try {
      attachment.isLoadingContent = true;
      attachments.refresh();
      update();
      String? content = await AttachmentService.readAttachmentContent(
        attachment.id,
      );
      noteContent.value = content ?? "";
      attachment.isLoadingContent = false;
      update();
      attachments.refresh();
    } catch (e) {
      attachment.isLoadingContent = false;
      noteContent.value = "";
      attachments.refresh();
      update();
    }
  } else {
    noteContent.value = "";
  }
  noteNameController.text = noteName.value;
  noteContentController.text = noteContent.value;
  openAttachmentNote.value = attachment;
  update();
  showAttachmentNoteModal(isEditable: isEditable);
}