MenuController class

A controller used to manage a menu created by a subclass of RawMenuAnchor, such as MenuAnchor, MenuBar, SubmenuButton.

A MenuController is used to control and interrogate a menu after it has been created, with methods such as open and close, and state accessors like isOpen.

MenuController.maybeOf can be used to retrieve a controller from the BuildContext of a widget that is a descendant of a MenuAnchor, MenuBar, SubmenuButton, or RawMenuAnchor. Doing so will not establish a dependency relationship.

See also:

  • MenuAnchor, a menu anchor that follows the Material Design guidelines.
  • MenuBar, a widget that creates a menu bar that can take an optional MenuController.
  • SubmenuButton, a widget that has a button that manages a submenu.
  • RawMenuAnchor, a widget that defines a region that has submenu.

Constructors

Properties

hashCode → int
The hash code for this object.
no setterinherited
isOpen → bool
Whether or not the menu associated with this MenuController is open.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

close() → void
Close the menu that this MenuController is associated with.
closeChildren() → void
Close the children of the menu associated with this MenuController, without closing the menu itself.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open({Offset? position}) → void
Opens the menu that this MenuController is associated with.
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

maybeIsOpenOf(BuildContext context) → bool?
Returns the value of MenuController.isOpen of the ancestor RawMenuAnchor or RawMenuAnchorGroup nearest to the given context, if one exists. Otherwise, returns null.
maybeOf(BuildContext context) → MenuController?
Returns the MenuController of the ancestor RawMenuAnchor nearest to the given context, if one exists. Otherwise, returns null.