onOpenRequested property

RawMenuAnchorOpenRequestedCallback onOpenRequested
final

Called when a request is made to open the menu.

This callback is triggered every time MenuController.open is called, even when the menu overlay is already showing. As a result, this callback is a good place to begin menu opening animations, or observe when a menu is repositioned.

After an open request is intercepted, the showOverlay callback should be called when the menu overlay (the widget built by overlayBuilder) is ready to be shown. This can occur immediately (the default behavior), or after a delay. Calling showOverlay sets MenuController.isOpen to true, builds (or rebuilds) the overlay widget, and shows the menu overlay at the front of the overlay stack.

If showOverlay is not called, the menu will stay hidden. Calling showOverlay after disposal is a no-op, meaning it will not trigger onOpen or show the menu overlay.

If a RawMenuAnchor is used in a themed menu that plays an opening animation, the themed menu should show the overlay before starting the opening animation, since the animation plays on the overlay itself.

The position argument is the position that MenuController.open was called with.

A typical onOpenRequested consists of the following steps:

  1. Optional delay.
  2. Call showOverlay (whose call chain eventually invokes onOpen).
  3. Optionally start the opening animation.

Defaults to a callback that immediately shows the menu.

Implementation

final RawMenuAnchorOpenRequestedCallback onOpenRequested;