From 36a68e97711d459a70705859e5a3ca77538fbc3b Mon Sep 17 00:00:00 2001 From: Peter Fischer Date: Wed, 14 Aug 2024 08:52:57 +0200 Subject: [PATCH] [navigation] fix bug in Get.until/GetDelegate.backUntil backUntil should pop while there is more than one route stacked fixes #2932 --- .../src/routes/get_router_delegate.dart | 2 +- test/navigation/get_main_test.dart | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/get_navigation/src/routes/get_router_delegate.dart b/lib/get_navigation/src/routes/get_router_delegate.dart index b8798cc4..d69b970d 100644 --- a/lib/get_navigation/src/routes/get_router_delegate.dart +++ b/lib/get_navigation/src/routes/get_router_delegate.dart @@ -627,7 +627,7 @@ class GetDelegate extends RouterDelegate @override void backUntil(bool Function(GetPage) predicate) { - while (_activePages.length <= 1 && !predicate(_activePages.last.route!)) { + while (_activePages.length > 1 && !predicate(_activePages.last.route!)) { _popWithResult(); } diff --git a/test/navigation/get_main_test.dart b/test/navigation/get_main_test.dart index 240ae5a4..03cd965a 100644 --- a/test/navigation/get_main_test.dart +++ b/test/navigation/get_main_test.dart @@ -416,6 +416,28 @@ void main() { expect(find.byType(FirstScreen), findsOneWidget); }); + testWidgets("Get.until", (tester) async { + await tester.pumpWidget(WrapperNamed( + initialRoute: '/first', + namedRoutes: [ + GetPage(page: () => const FirstScreen(), name: '/first'), + GetPage(page: () => const SecondScreen(), name: '/second'), + GetPage(page: () => const ThirdScreen(), name: '/third') + ], + )); + + await tester.pump(); + + Get.toNamed('/second'); + await tester.pumpAndSettle(); + Get.toNamed('/third'); + await tester.pumpAndSettle(); + Get.until((route) => route.name == '/first'); + await tester.pumpAndSettle(); + + expect(find.byType(FirstScreen), findsOneWidget); + }); + group("Get.defaultTransition smoke test", () { testWidgets("fadeIn", (tester) async { await tester.pumpWidget(