From 688211ddf6481f38a4f3d6c0a33c29c955062e6e Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Fri, 2 Feb 2024 13:38:21 +0100 Subject: [PATCH] Respect allowCancel in dialog mode --- lib/widgets/responsive_dialog.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/widgets/responsive_dialog.dart b/lib/widgets/responsive_dialog.dart index a6ea00f0..226bc36c 100755 --- a/lib/widgets/responsive_dialog.dart +++ b/lib/widgets/responsive_dialog.dart @@ -76,6 +76,7 @@ class _ResponsiveDialogState extends State { ? l10n.s_close : l10n.s_cancel; return PopScope( + canPop: widget.allowCancel, child: AlertDialog( title: widget.title, titlePadding: const EdgeInsets.only(top: 24, left: 18, right: 18), @@ -87,10 +88,12 @@ class _ResponsiveDialogState extends State { ), actions: [ TextButton( + onPressed: widget.allowCancel + ? () { + Navigator.of(context).pop(); + } + : null, child: Text(cancelText), - onPressed: () { - Navigator.of(context).pop(); - }, ), ...widget.actions ],