tweaking download

This commit is contained in:
verboomp
2026-02-06 13:45:35 +01:00
parent 7819b963f2
commit 2955a7eb1c

View File

@@ -337,8 +337,24 @@ class _CustomerWidgetState extends State<CustomerWidget> {
} }
Future<void> _actionDownload(BuildContext context, CustomerDto customerDto, PictureDto? pictureDto) async { Future<void> _actionDownload(BuildContext context, CustomerDto customerDto, PictureDto? pictureDto) async {
final bytes = await _customerController.export(customerId: customerDto.id, pictureId: pictureDto?.id); showDialog(
final fileName = pictureDto != null ? '${customerDto.customerNumber}_${pictureDto.id}.pdf' : '${customerDto.customerNumber}.pdf'; context: context,
await downloadFile(bytes, fileName); barrierDismissible: false,
builder: (context) => const Center(child: CircularProgressIndicator()),
);
try {
final bytes = await _customerController.export(customerId: customerDto.id, pictureId: pictureDto?.id);
final fileName = pictureDto != null ? '${customerDto.customerNumber}_${pictureDto.id}.pdf' : '${customerDto.customerNumber}.pdf';
if (context.mounted) {
Navigator.of(context).pop();
}
await downloadFile(bytes, fileName);
} catch (e) {
if (context.mounted) {
Navigator.of(context).pop();
}
rethrow;
}
} }
} }