From dcb50951b2cfe0ae17c304b9939f632ca430b874 Mon Sep 17 00:00:00 2001 From: Ruchi Mulik Date: Sun, 7 Dec 2025 07:57:50 +0530 Subject: [PATCH] fix: make 'No' button discard and allow pop in unsaved-changes dialog --- .../detailRoute/views/detail_route_view.dart | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/app/modules/detailRoute/views/detail_route_view.dart b/lib/app/modules/detailRoute/views/detail_route_view.dart index 0d194ce6..f62c48a7 100644 --- a/lib/app/modules/detailRoute/views/detail_route_view.dart +++ b/lib/app/modules/detailRoute/views/detail_route_view.dart @@ -52,6 +52,7 @@ class DetailRouteView extends GetView { ), ), actions: [ + // YES → save and pop TextButton( onPressed: () { // Get.back(); // Close the dialog first @@ -73,11 +74,12 @@ class DetailRouteView extends GetView { ), ), ), + + // NO → discard and pop TextButton( onPressed: () { // Get.offAll(() => const HomeView()); - - Navigator.of(context).pop(); + Navigator.of(context).pop(false); }, child: Text( SentenceManager( @@ -89,9 +91,11 @@ class DetailRouteView extends GetView { ), ), ), + + // CANCEL → stay on page TextButton( onPressed: () { - Navigator.of(context).pop(false); + Navigator.of(context).pop(null); }, child: Text( SentenceManager( @@ -107,7 +111,12 @@ class DetailRouteView extends GetView { ); }, ); - return save == true; + if (save == null) { + // Cancel → stay + return false; + } + // Yes (true) or No (false) → both allow popping the screen + return true; }, child: Scaffold( backgroundColor: tColors.primaryBackgroundColor,