fix download image

This commit is contained in:
Salvatore Giordano
2021-04-30 15:00:52 +02:00
parent 236f0a4f15
commit 75e167b4ed
@@ -120,7 +120,7 @@ class AttachmentActionsModal extends StatelessWidget {
received, received,
); );
}, },
).catchError((_) { ).catchError((e, stk) {
progressNotifier.value = null; progressNotifier.value = null;
}); });
@@ -225,16 +225,14 @@ class AttachmentActionsModal extends StatelessWidget {
ValueNotifier<_DownloadProgress?> progressNotifier, ValueNotifier<_DownloadProgress?> progressNotifier,
) { ) {
final theme = StreamChatTheme.of(context); final theme = StreamChatTheme.of(context);
return WillPopScope( return ValueListenableBuilder(
onWillPop: () => Future.value(false),
child: ValueListenableBuilder(
valueListenable: progressNotifier, valueListenable: progressNotifier,
builder: (_, _DownloadProgress? progress, __) { builder: (_, _DownloadProgress? progress, __) {
// Pop the dialog in case the progress is null or it's completed. // Pop the dialog in case the progress is null or it's completed.
if (progress == null || progress.toProgressIndicatorValue == 1.0) { if (progress == null || progress.toProgressIndicatorValue == 1.0) {
Future.delayed( Future.delayed(
const Duration(milliseconds: 500), const Duration(milliseconds: 500),
Navigator.of(context).maybePop, () => Navigator.of(context).maybePop(),
); );
} }
return Material( return Material(
@@ -294,7 +292,6 @@ class AttachmentActionsModal extends StatelessWidget {
), ),
); );
}, },
),
); );
} }
@@ -310,7 +307,7 @@ class AttachmentActionsModal extends StatelessWidget {
final contentType = responseHeaders[Headers.contentTypeHeader]!; final contentType = responseHeaders[Headers.contentTypeHeader]!;
final mimeType = contentType.first.split('/').last; final mimeType = contentType.first.split('/').last;
filePath ??= '${appDocDir.path}/${attachment.id}.$mimeType'; filePath ??= '${appDocDir.path}/${attachment.id}.$mimeType';
return filePath; return filePath!;
}, },
onReceiveProgress: progressCallback, onReceiveProgress: progressCallback,
); );