Skip to content

[material_ui] Document how to programmatically clear DropdownMenu selection - #13266

Open
dkbharti-glitch wants to merge 1 commit into
flutter:mainfrom
dkbharti-glitch:dropdown-menu-clear-doc
Open

dkbharti-glitch wants to merge 1 commit into
flutter:mainfrom
dkbharti-glitch:dropdown-menu-clear-doc

Conversation

@dkbharti-glitch

@dkbharti-glitch dkbharti-glitch commented Oct 15, 2026 •

Copy link
Copy Markdown

Description

Clarifies how to programmatically clear or reset the selection in DropdownMenu.

Setting initialSelection to null does not clear the text field because it only sets the initial value. This PR documents that providing a TextEditingController and calling controller.clear() alongside updating the state variable to null is required to reset the selection, and adds an interactive code sample demonstrating this pattern.

Fixes flutter/flutter#177599

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Oct 15, 2026
@google-cla

google-cla Bot commented Oct 15, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Oct 15, 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 adds a new code sample and widget tests demonstrating how to programmatically clear or reset the selection in a DropdownMenu using a TextEditingController. It also updates the documentation for DropdownMenu, its controller property, and its initialSelection property to explain this behavior and reference the new example. A pending changelog entry is also included. There are no review comments, and I have no feedback to provide.

…ection

Improve documentation and add an interactive sample demonstrating how to programmatically clear or reset the selection in DropdownMenu using a TextEditingController alongside resetting the state variable.

Fixes flutter/flutter#177599
@dkbharti-glitch
dkbharti-glitch force-pushed the dropdown-menu-clear-doc branch from ea69ee2 to 90aa5d2 Compare October 23, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD 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.

[DropdownMenu] Improve document on how to reset selectedValue

1 participant