downloadMediaAs method
- List<
Attachment> attachments
Downloads the provided image or video attachments
using save as
dialog.
Implementation
Future<void> downloadMediaAs(List<Attachment> attachments) async {
try {
String? to =
attachments.length > 1
? await FilePicker.platform.getDirectoryPath(
lockParentWindow: true,
)
: await FilePicker.platform.saveFile(
fileName: attachments.first.filename,
type:
attachments.first is ImageAttachment
? FileType.image
: FileType.video,
lockParentWindow: true,
);
if (to != null) {
await downloadMedia(attachments, to: to);
}
} catch (_) {
MessagePopup.error('err_could_not_download'.l10n);
rethrow;
}
}