mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
![]() 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:
* Centralizes core menu logic to a private class,` _RawMenuAnchor()`,
* Provides the internals for interacting with menus:
* TapRegion interop
* DismissMenuAction handler
* Close on scroll/resize
* Focus traversal information, if applicable
* Subclasses override `_open`, `_close`, `_isOpen`, `_buildAnchor`, and
`_menuScopeNode`
* State is accessible by descendents via
`MenuController.maybeOf(context)._anchor`
* Adds 2 public constructors, backed by a `_RawMenuAnchor()` that
contains shared logic.
* `RawMenuAnchor()`
* Users build the overlay from scratch.
* Provides anchor/overlay position information and TapRegionGroupId to
builder
* Does not provide FocusScope management.
* `RawMenuAnchorGroup()`
* A primitive for menus that do not have overlays (menu bars).
* This was previously called RawMenuAnchor.node(), but @dkwingsmt made a
good case for splitting out the constructor.
<s>Documentation examples have been added, and can be viewed at
https://menu-anchor.web.app/</s>
<s>https://github.com/user-attachments/assets/25d35f23-2aad-4d07-9172-5c3fd65d53cf</s>
@dkwingsmt
List which issues are fixed by this PR.
https://github.com/flutter/flutter/pull/143712
Some issues that need to be addressed:
Semantics:
<img width="1027" alt="image"
src="https://github.com/user-attachments/assets/d69661c9-8435-4d9c-b200-474968cb57eb">
I'm basing the menu semantics off of the comment
[here](
|
||
---|---|---|
.. | ||
actions | ||
animated_grid | ||
animated_list | ||
animated_size | ||
animated_switcher | ||
app | ||
app_lifecycle_listener | ||
async | ||
autocomplete | ||
autofill | ||
basic | ||
binding | ||
color_filter | ||
dismissible | ||
drag_target | ||
draggable_scrollable_sheet | ||
editable_text | ||
focus_manager | ||
focus_scope | ||
focus_traversal | ||
form | ||
framework | ||
gesture_detector | ||
hardware_keyboard | ||
heroes | ||
image | ||
implicit_animations | ||
inherited_model | ||
inherited_notifier | ||
inherited_theme | ||
interactive_viewer | ||
layout_builder | ||
magnifier | ||
media_query | ||
navigator | ||
navigator_pop_handler | ||
nested_scroll_view | ||
notification_listener | ||
overflow_bar | ||
overlay | ||
overscroll_indicator | ||
page | ||
page_storage | ||
page_view | ||
pop_scope | ||
preferred_size | ||
raw_menu_anchor | ||
restoration | ||
restoration_properties | ||
routes | ||
safe_area | ||
scroll_end_notification | ||
scroll_notification_observer | ||
scroll_position | ||
scroll_view | ||
scrollbar | ||
shared_app_data | ||
shortcuts | ||
single_child_scroll_view | ||
sliver | ||
sliver_fill | ||
slotted_render_object_widget | ||
system_context_menu | ||
table | ||
tap_region | ||
text | ||
text_magnifier | ||
transitions | ||
tween_animation_builder | ||
undo_history | ||
value_listenable_builder | ||
widget_state | ||
navigator_utils.dart |