onCloseRequested property
Called when a request is made to close the menu.
This callback is triggered every time MenuController.close is called, regardless of whether the overlay is already hidden. As a result, this callback can be used to add a delay or a closing animation before the menu is hidden.
If the menu is not closed, this callback will also be called when the root menu anchor is scrolled and when the screen is resized.
After a close request is intercepted and closing behaviors have completed,
the hideOverlay
callback should be called. This callback sets
MenuController.isOpen to false and hides the menu overlay widget. If the
RawMenuAnchor is used in a themed menu that plays a closing animation,
hideOverlay
should be called after the closing animation has ended,
since the animation plays on the overlay itself. This means that
MenuController.isOpen will stay true while closing animations are
running.
Calling hideOverlay
after disposal is a no-op, meaning it will not
trigger onClose or hide the menu overlay.
Typically, onCloseRequested consists of the following steps:
- Optionally start the closing animation and wait for it to complete.
- Call
hideOverlay
(whose call chain eventually invokes onClose).
Throughout the closing sequence, menus should typically not be focusable or interactive.
Defaults to a callback that immediately hides the menu.
Implementation
final RawMenuAnchorCloseRequestedCallback onCloseRequested;