Skip to content

Commit a4b1ebb

Browse files
authored
[go_router] Sets correct reverseTransitionDuration on NoTransitionPage (flutter#123368) (flutter#3540)
[go_router] Sets correct reverseTransitionDuration on NoTransitionPage (flutter#123368)
1 parent 751ea41 commit a4b1ebb

4 files changed

Lines changed: 51 additions & 15 deletions

File tree

packages/go_router/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 6.5.2
2+
3+
- NoTransitionPage now has an instant reverse transition
4+
15
## 6.5.1
26

37
- Fixes an issue where the params are removed after popping.

packages/go_router/lib/src/pages/custom_transition_page.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ class NoTransitionPage<T> extends CustomTransitionPage<T> {
175175
super.key,
176176
}) : super(
177177
transitionsBuilder: _transitionsBuilder,
178-
transitionDuration: const Duration(microseconds: 1),
178+
transitionDuration: Duration.zero,
179+
reverseTransitionDuration: Duration.zero,
179180
);
180181

181182
static Widget _transitionsBuilder(

packages/go_router/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: go_router
22
description: A declarative router for Flutter based on Navigation 2 supporting
33
deep linking, data-driven routes and more
4-
version: 6.5.1
4+
version: 6.5.2
55
repository: https://github.com/flutter/packages/tree/main/packages/go_router
66
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22
77

packages/go_router/test/custom_transition_page_test.dart

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,59 @@ void main() {
6161

6262
final Finder homeScreenFinder = find.byType(HomeScreen);
6363

64+
expect(homeScreenFinder, findsNothing);
65+
6466
showHomeValueNotifier.value = true;
67+
6568
await tester.pump();
66-
final Offset homeScreenPositionInTheMiddleOfAddition =
67-
tester.getTopLeft(homeScreenFinder);
69+
70+
expect(homeScreenFinder, findsOneWidget);
71+
6872
await tester.pumpAndSettle();
69-
final Offset homeScreenPositionAfterAddition =
70-
tester.getTopLeft(homeScreenFinder);
7173

7274
showHomeValueNotifier.value = false;
75+
7376
await tester.pump();
74-
final Offset homeScreenPositionInTheMiddleOfRemoval =
75-
tester.getTopLeft(homeScreenFinder);
77+
78+
expect(homeScreenFinder, findsNothing);
79+
7680
await tester.pumpAndSettle();
81+
});
7782

78-
expect(
79-
homeScreenPositionInTheMiddleOfAddition,
80-
homeScreenPositionAfterAddition,
81-
);
82-
expect(
83-
homeScreenPositionAfterAddition,
84-
homeScreenPositionInTheMiddleOfRemoval,
83+
testWidgets('NoTransitionPage does not apply any reverse transition',
84+
(WidgetTester tester) async {
85+
final ValueNotifier<bool> showHomeValueNotifier = ValueNotifier<bool>(true);
86+
await tester.pumpWidget(
87+
MaterialApp(
88+
home: ValueListenableBuilder<bool>(
89+
valueListenable: showHomeValueNotifier,
90+
builder: (_, bool showHome, __) {
91+
return Navigator(
92+
pages: <Page<void>>[
93+
const NoTransitionPage<void>(
94+
child: LoginScreen(),
95+
),
96+
if (showHome)
97+
const NoTransitionPage<void>(
98+
child: HomeScreen(),
99+
),
100+
],
101+
onPopPage: (Route<dynamic> route, dynamic result) {
102+
return route.didPop(result);
103+
},
104+
);
105+
},
106+
),
107+
),
85108
);
109+
110+
final Finder homeScreenFinder = find.byType(HomeScreen);
111+
112+
showHomeValueNotifier.value = false;
113+
114+
await tester.pump();
115+
116+
expect(homeScreenFinder, findsNothing);
86117
});
87118

88119
testWidgets('Dismiss a screen by tapping a modal barrier',

0 commit comments

Comments
 (0)