From 79d668e004a46b9564a1f0df06a12375415c4979 Mon Sep 17 00:00:00 2001 From: otsmr Date: Wed, 29 Jul 2026 14:22:22 +0200 Subject: [PATCH] fix black screen issue --- lib/src/utils/misc.dart | 4 ++++ .../visual/views/chats/media_viewer.view.dart | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/src/utils/misc.dart b/lib/src/utils/misc.dart index 2c8428eb..a92c8bdf 100644 --- a/lib/src/utils/misc.dart +++ b/lib/src/utils/misc.dart @@ -210,6 +210,10 @@ Future authenticateUser( return true; } } + } catch (e) { + // Catch unexpected platform exceptions (e.g. PlatformException) that + // would otherwise propagate and leave callers in a broken state. + Log.error('Unexpected authentication error: $e'); } return false; } diff --git a/lib/src/visual/views/chats/media_viewer.view.dart b/lib/src/visual/views/chats/media_viewer.view.dart index 5cc36dda..c46bfb35 100644 --- a/lib/src/visual/views/chats/media_viewer.view.dart +++ b/lib/src/visual/views/chats/media_viewer.view.dart @@ -671,6 +671,25 @@ class _MediaViewerViewState extends State { child: Stack( fit: StackFit.expand, children: [ + // Fallback: when no content is visible (no media, no loader, + // no twonly-present overlay), show a loader to prevent a + // black screen. If there are truly no files left, exit. + if (!_showDownloadingLoader && + currentMedia == null && + videoController == null && + !displayTwonlyPresent) + Builder(builder: (context) { + // Schedule exit on the next frame if there is nothing + // left to display, so we don't trap the user. + if (allMediaFiles.isEmpty) { + WidgetsBinding.instance.addPostFrameCallback((_) { + if (mounted && currentMedia == null) { + Navigator.of(context).maybePop(); + } + }); + } + return _loader(); + }), if (_showDownloadingLoader) _loader(), if ((currentMedia != null || videoController != null) && (canBeSeenUntil == null || progress.value >= 0))