Unverified Commit 220cceed authored by Dan Field's avatar Dan Field Committed by GitHub

Fix heroes transition when initial route is not '/' (#24039)

* early return for initialRoute + test
parent 028087d0
......@@ -598,9 +598,18 @@ class HeroController extends NavigatorObserver {
final PageRoute<dynamic> to = toRoute;
final Animation<double> animation = (flightType == HeroFlightDirection.push) ? to.animation : from.animation;
// A user gesture may have already completed the pop.
if (flightType == HeroFlightDirection.pop && animation.status == AnimationStatus.dismissed) {
return;
// A user gesture may have already completed the pop, or we might be the initial route
switch (flightType) {
case HeroFlightDirection.pop:
if (animation.value == 0.0) {
return;
}
break;
case HeroFlightDirection.push:
if (animation.value == 1.0) {
return;
}
break;
}
// For pop transitions driven by a user gesture: if the "to" page has
......
......@@ -1437,4 +1437,12 @@ void main() {
expect(find.byKey(firstKey), isInCard);
expect(find.byKey(secondKey), findsNothing);
});
testWidgets('Handles transitions when a non-default initial route is set', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
routes: routes,
initialRoute: '/two',
));
expect(find.text('two'), findsOneWidget);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment