Skip to content

Commit ea66fb0

Browse files
authored
fix: make 'No' button discard and allow pop in unsaved-changes dialog
PR (#512)
1 parent eedbe5c commit ea66fb0

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

lib/app/modules/detailRoute/views/detail_route_view.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class DetailRouteView extends GetView<DetailRouteController> {
5252
),
5353
),
5454
actions: [
55+
// YES → save and pop
5556
TextButton(
5657
onPressed: () {
5758
// Get.back(); // Close the dialog first
@@ -73,11 +74,12 @@ class DetailRouteView extends GetView<DetailRouteController> {
7374
),
7475
),
7576
),
77+
78+
// NO → discard and pop
7679
TextButton(
7780
onPressed: () {
7881
// Get.offAll(() => const HomeView());
79-
80-
Navigator.of(context).pop();
82+
Navigator.of(context).pop(false);
8183
},
8284
child: Text(
8385
SentenceManager(
@@ -89,9 +91,11 @@ class DetailRouteView extends GetView<DetailRouteController> {
8991
),
9092
),
9193
),
94+
95+
// CANCEL → stay on page
9296
TextButton(
9397
onPressed: () {
94-
Navigator.of(context).pop(false);
98+
Navigator.of(context).pop(null);
9599
},
96100
child: Text(
97101
SentenceManager(
@@ -107,7 +111,12 @@ class DetailRouteView extends GetView<DetailRouteController> {
107111
);
108112
},
109113
);
110-
return save == true;
114+
if (save == null) {
115+
// Cancel → stay
116+
return false;
117+
}
118+
// Yes (true) or No (false) → both allow popping the screen
119+
return true;
111120
},
112121
child: Scaffold(
113122
backgroundColor: tColors.primaryBackgroundColor,

0 commit comments

Comments
 (0)