diff --git a/lib/widget/dialogs.dart b/lib/widget/dialogs.dart index 61da23e9..0c084095 100644 --- a/lib/widget/dialogs.dart +++ b/lib/widget/dialogs.dart @@ -224,6 +224,11 @@ Widget _buildErrorContent(String description, APIResponse? response) { ); } +// Track whether an error dialog is currently being displayed, +// so that we do not stack multiple error dialogs on top of each other +// (e.g. when several API requests fail in quick succession on startup) +bool _errorDialogVisible = false; + /* * Construct an error dialog showing information to the user * @@ -243,6 +248,13 @@ Future showErrorDialog( return; } + // Do not show a new error dialog if one is already visible + if (_errorDialogVisible) { + return; + } + + _errorDialogVisible = true; + final Color dialogColor = color ?? COLOR_DANGER; OneContext() @@ -263,6 +275,7 @@ Future showErrorDialog( ), ) .then((value) { + _errorDialogVisible = false; if (onDismissed != null) { onDismissed(); }