@@ -3342,6 +3342,61 @@ void main() {
3342
3342
expect (find.text ('forth' ), findsOneWidget);
3343
3343
});
3344
3344
3345
+ //Regression test for https://github.com/flutter/flutter/issues/115887
3346
+ testWidgets ('Complex case 2' , (WidgetTester tester) async {
3347
+ final GlobalKey <NavigatorState > navigator = GlobalKey <NavigatorState >();
3348
+ List <TestPage > myPages = < TestPage > [
3349
+ const TestPage (key: ValueKey <String >('1' ), name: 'initial' ),
3350
+ const TestPage (key: ValueKey <String >('2' ), name: 'second' ),
3351
+ ];
3352
+
3353
+ bool onPopPage (Route <dynamic > route, dynamic result) {
3354
+ myPages.removeWhere ((Page <dynamic > page) => route.settings == page);
3355
+ return route.didPop (result);
3356
+ }
3357
+
3358
+ await tester.pumpWidget (
3359
+ buildNavigator (pages: myPages, onPopPage: onPopPage, key: navigator),
3360
+ );
3361
+ expect (find.text ('second' ), findsOneWidget);
3362
+ expect (find.text ('initial' ), findsNothing);
3363
+ // Push pageless route to second page route
3364
+ navigator.currentState! .push (
3365
+ MaterialPageRoute <void >(
3366
+ builder: (BuildContext context) => const Text ('second-pageless1' ),
3367
+ ),
3368
+ );
3369
+
3370
+ await tester.pumpAndSettle ();
3371
+ // Now the history should look like [initial, second, second-pageless1].
3372
+ expect (find.text ('initial' ), findsNothing);
3373
+ expect (find.text ('second' ), findsNothing);
3374
+ expect (find.text ('second-pageless1' ), findsOneWidget);
3375
+ expect (myPages.length, 2 );
3376
+
3377
+ myPages = < TestPage > [
3378
+ const TestPage (key: ValueKey <String >('2' ), name: 'second' ),
3379
+ ];
3380
+ await tester.pumpWidget (
3381
+ buildNavigator (pages: myPages, onPopPage: onPopPage, key: navigator),
3382
+ );
3383
+ await tester.pumpAndSettle ();
3384
+
3385
+ // Now the history should look like [second, second-pageless1].
3386
+ expect (find.text ('initial' ), findsNothing);
3387
+ expect (find.text ('second' ), findsNothing);
3388
+ expect (find.text ('second-pageless1' ), findsOneWidget);
3389
+ expect (myPages.length, 1 );
3390
+
3391
+ // Pop the pageless route.
3392
+ navigator.currentState! .pop ();
3393
+ await tester.pumpAndSettle ();
3394
+ expect (myPages.length, 1 );
3395
+ expect (find.text ('initial' ), findsNothing);
3396
+ expect (find.text ('second' ), findsOneWidget);
3397
+ expect (find.text ('second-pageless1' ), findsNothing);
3398
+ });
3399
+
3345
3400
testWidgets ('complex case 1 - with always remove transition delegate' , (WidgetTester tester) async {
3346
3401
final GlobalKey <NavigatorState > navigator = GlobalKey <NavigatorState >();
3347
3402
final AlwaysRemoveTransitionDelegate transitionDelegate = AlwaysRemoveTransitionDelegate ();
0 commit comments