Skip to content

[material_ui] Port PR (#187366) from flutter/flutter to material_ui - #12821

Open
ishivamg wants to merge 1 commit into
flutter:mainfrom
ishivamg:port/187366-dropdown-orientation-crash
Open

[material_ui] Port PR (#187366) from flutter/flutter to material_ui#12821
ishivamg wants to merge 1 commit into
flutter:mainfrom
ishivamg:port/187366-dropdown-orientation-crash

Conversation

@ishivamg

Copy link
Copy Markdown

This PR ports flutter/flutter#187366 to material_ui.

When a DropdownButton menu is open (especially inside a dialog) and the device orientation changes, _DropdownButtonState.build() dismissed the route with Navigator.removeRoute() during build. That triggers setState() or markNeedsBuild() called during build.

The route is now removed synchronously unless we are in SchedulerPhase.persistentCallbacks, in which case removal is deferred to a post-frame callback.

Fixes flutter/flutter#171011
Follows flutter/flutter#188444

…nu is open

Defer Navigator.removeRoute until after the current frame when orientation
changes during build. This ports the reviewed fix from flutter/flutter#187366.

Fixes flutter/flutter#171011
@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Sep 10, 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 defers the dismissal of the dropdown route during orientation changes if the scheduler is in the persistent callbacks phase, preventing Navigator mutation during the build phase. It also adds a corresponding widget test to verify this behavior and a changelog entry. There are no review comments, and I have no feedback to provide.

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

Labels

p: material_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opening dropdownMenu from alertDialog and rotating the screen throws error.

1 participant