Implement RawMenuAnchor#158255
Merged
auto-submit[bot] merged 100 commits intoflutter:masterfrom Feb 4, 2025
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a
RawMenuAnchor()widget to widgets.dart. The purpose of this widget is to provide a menu primitive for the Material and Cupertino libraries (and others) to build upon. Additionally, this PR makes MenuController an inherited widget to simplify nested access to the menu (e.g. if you want to launch a context menu from a deeply-nested widget).This PR:
_RawMenuAnchor(),_open,_close,_isOpen,_buildAnchor, and_menuScopeNodeMenuController.maybeOf(context)._anchor_RawMenuAnchor()that contains shared logic.RawMenuAnchor()RawMenuAnchorGroup()Documentation examples have been added, and can be viewed at https://menu-anchor.web.app/https://github.com/user-attachments/assets/25d35f23-2aad-4d07-9172-5c3fd65d53cf@dkwingsmt
List which issues are fixed by this PR. #143712
Some issues that need to be addressed:
Semantics:

I'm basing the menu semantics off of the comment here, but I'm unsure whether the route should be given a name. There is no menubar/menu/menuitem role in Flutter, so I'm assuming the menu should be composed of nested dialogs
Unlike the menubar pattern from W3C, the RawMenuAnchorWhile it is possible to nest menus -- for example, a dropdown anchor within a full-app context menu area -- nested menus behave as a single group. I was considering adding an additional parameter that separates nested root menus from their parents, and am interested to hear your feedback.If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.