From b15c83d957a589061b1db8dd6578dd6a83957225 Mon Sep 17 00:00:00 2001 From: Dio Maulana Date: Mon, 1 Apr 2024 16:00:14 +0700 Subject: [PATCH] implement popscope to ignore backbutton android --- lib/cool_alert.dart | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/cool_alert.dart b/lib/cool_alert.dart index a4c6589..fe8a89f 100644 --- a/lib/cool_alert.dart +++ b/lib/cool_alert.dart @@ -107,6 +107,7 @@ class CoolAlert { /// Reverse the order of the buttons bool reverseBtnOrder = false, + bool canPop = false, }) { if (autoCloseDuration != null) { Future.delayed(autoCloseDuration, () { @@ -143,13 +144,16 @@ class CoolAlert { reverseBtnOrder: reverseBtnOrder, ); - final child = AlertDialog( - contentPadding: EdgeInsets.zero, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(borderRadius), - ), - content: CoolAlertContainer( - options: options, + final child = PopScope( + canPop: canPop, + child: AlertDialog( + contentPadding: EdgeInsets.zero, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(borderRadius), + ), + content: CoolAlertContainer( + options: options, + ), ), );