getAttachmentFromDevice method
Future<void>
getAttachmentFromDevice(
)
Implementation
Future<void> getAttachmentFromDevice() async {
List<File>? files = await FileService.getFileFromDevice(
allowMultiple: true,
);
if (files.isEmpty) return;
sendingAttachments.value = sendingAttachments.value + files.length;
update();
try {
bool conversationExists = await checkConversationExists(files.length);
if (!conversationExists) return;
for (File file in files) {
Attachment? newAttachment = await AttachmentService.postAttachment(
file,
);
if (newAttachment != null) attachments.add(newAttachment);
if (sendingAttachments.value <= 0) {
sendingAttachments.value = 0;
} else {
sendingAttachments.value--;
}
attachments.refresh();
update();
}
if (files.length > 1) {
showFeedbackSnackbar(
Strings.attachmentUploadSuccessMultiple.tr,
Symbols.attachment,
);
} else {
showFeedbackSnackbar(
Strings.attachmentUploadSuccess.tr,
Symbols.attachment,
);
}
} catch (e) {
sendingAttachments.value = 0;
update();
}
}