From 2955a7eb1cd64489a303ceaa3096401f34896a47 Mon Sep 17 00:00:00 2001 From: verboomp Date: Fri, 6 Feb 2026 13:45:35 +0100 Subject: [PATCH] tweaking download --- .../lib/pages/customer/customer_widget.dart | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/hartmann-foto-documentation-frontend/lib/pages/customer/customer_widget.dart b/hartmann-foto-documentation-frontend/lib/pages/customer/customer_widget.dart index c530121..7c12996 100644 --- a/hartmann-foto-documentation-frontend/lib/pages/customer/customer_widget.dart +++ b/hartmann-foto-documentation-frontend/lib/pages/customer/customer_widget.dart @@ -337,8 +337,24 @@ class _CustomerWidgetState extends State { } Future _actionDownload(BuildContext context, CustomerDto customerDto, PictureDto? pictureDto) async { - final bytes = await _customerController.export(customerId: customerDto.id, pictureId: pictureDto?.id); - final fileName = pictureDto != null ? '${customerDto.customerNumber}_${pictureDto.id}.pdf' : '${customerDto.customerNumber}.pdf'; - await downloadFile(bytes, fileName); + showDialog( + context: context, + 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; + } } }