Sitelet https://github.com/flutter/flutter/pull/190025
Skip to content

Fix Hero size changes during Navigator resize - #190025

Merged
jtmcdole merged 6 commits into
flutter:masterfrom
MTtankkeo:hero
Aug 7, 2026
Merged

jtmcdole merged 6 commits into
flutter:masterfrom
MTtankkeo:hero

Conversation

@MTtankkeo

Copy link
Copy Markdown

Fixes #134647

Description

Hero flights were positioned by converting the evaluated flight Rect into a RelativeRect using the Navigator size captured when the flight started.

This caused the Hero's size or position to become distorted if the Navigator resized during the transition. It was especially visible with nested Navigators because they can be resized by their parent layout, for example when a Scaffold shrinks in response to the keyboard. The root Navigator's Overlay typically keeps the full viewport size, so the issue was less likely to occur there.

This change positions the Hero directly from the evaluated Rect, avoiding calculations based on stale Navigator dimensions.

A regression test was added that resizes a nested Navigator during a Hero flight and verifies that the shuttle preserves its size.

Demonstration

Previous / Current Video
Previous.mp4
Current.mp4

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates _HeroFlight in heroes.dart to use Positioned.fromRect for positioning the hero shuttle. It also adds a widget test in heroes_test.dart to ensure that a Hero does not resize when its Navigator resizes during flight. There are no review comments, so I have no feedback to provide.

Comment thread packages/flutter/test/widgets/heroes_test.dart Outdated
Comment thread packages/flutter/test/widgets/heroes_test.dart Outdated
Comment thread packages/flutter/test/widgets/heroes_test.dart Outdated
Comment thread packages/flutter/test/widgets/heroes_test.dart Outdated
navaronbracke
navaronbracke previously approved these changes Jul 25, 2026
@navaronbracke navaronbracke added the CICD Run CI/CD label Jul 25, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Jul 25, 2026
@MTtankkeo

Copy link
Copy Markdown
Author

@navaronbracke The regression test failed due to an undisposed HeroController, so I fixed it!

navaronbracke
navaronbracke previously approved these changes Jul 26, 2026
Comment thread packages/flutter/test/widgets/heroes_test.dart Outdated
navaronbracke
navaronbracke previously approved these changes Jul 26, 2026
@Piinks
Piinks requested review from elliette and victorsanni August 4, 2026 22:27
@elliette elliette added the CICD Run CI/CD label Aug 5, 2026
elliette
elliette previously approved these changes Aug 5, 2026

@elliette elliette left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you!

@victorsanni victorsanni left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM with one dead code nit.

Comment thread packages/flutter/lib/src/widgets/heroes.dart
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Aug 5, 2026
@victorsanni victorsanni added the CICD Run CI/CD label Aug 5, 2026
@elliette elliette added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 6, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Aug 7, 2026
@jtmcdole
jtmcdole removed this pull request from the merge queue due to a manual request Aug 7, 2026
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 7, 2026
@jtmcdole
jtmcdole enabled auto-merge August 7, 2026 02:15
@jtmcdole
jtmcdole added this pull request to the merge queue Aug 7, 2026
@jtmcdole

jtmcdole commented Aug 7, 2026

Copy link
Copy Markdown
Member

removed and re-added to the queue; wasn't making progress and probably due to github actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hero size abnormally changes when the keyboard is open with HeroControllerScope and nested navigation

5 participants