Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Check to see if previous page is laid out before starting hero flight #169633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 2, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change check to look for size of RenderBox
  • Loading branch information
MitchellGoodwin committed Jun 2, 2025
commit 22311d7ddaf4bb70bf9d77dbdc42d06ce1db5ad8
17 changes: 7 additions & 10 deletions 17 packages/flutter/lib/src/widgets/heroes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -679,14 +679,9 @@ class _HeroFlight {
case HeroFlightDirection.pop:
return initialManifest.isUserGestureTransition
// During user gesture transitions, the animation controller isn't
// driving the reverse transition, but should have a starting value
// approaching 1.0. In cases where the toRoute begane offstage, there
// is a slight delay while the toRoute laysout before the hero's
// flight begins, so the animation may not begin completed.
? initial.value == 1.0
? initial.status == AnimationStatus.completed
: initial.status == AnimationStatus.forward
: initial.status == AnimationStatus.reverse;
// driving the reverse transition, so the status is not important.
||
initial.status == AnimationStatus.reverse;
case HeroFlightDirection.push:
return initial.value == 0.0 && initial.status == AnimationStatus.forward;
}
Expand Down Expand Up @@ -929,11 +924,13 @@ class HeroController extends NavigatorObserver {
// maintainState = true, then the hero's final dimensions can be measured
// immediately because their page's layout is still valid. Unless due to directly
// adding routes to the pages stack causing the route to never get laid out.
final bool needsLayout = toRoute.subtreeContext?.findRenderObject()?.debugNeedsLayout ?? true;
final RenderBox? fromRouteRenderBox = toRoute.subtreeContext?.findRenderObject() as RenderBox?;
final bool hasLayout =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final bool hasLayout =
final bool hasValidSize =

(fromRouteRenderBox?.hasSize ?? false) && fromRouteRenderBox!.size.isFinite;
if (isUserGestureTransition &&
flightType == HeroFlightDirection.pop &&
toRoute.maintainState &&
!needsLayout) {
hasLayout) {
_startHeroTransition(fromRoute, toRoute, flightType, isUserGestureTransition);
} else {
// Otherwise, delay measuring until the end of the next frame to allow
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.