MenuController class

A controller used to manage a menu created by a RawMenuAnchor, or RawMenuAnchorGroup.

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.

MenuController.maybeIsOpenOf can be used to interrogate the state of a menu from the BuildContext of a widget that is a descendant of a MenuAnchor. Unlike MenuController.maybeOf, this method will establish a dependency relationship, so the calling widget will rebuild when the menu opens and closes, and when the MenuController changes.

See also:

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 or RawMenuAnchorGroup nearest to the given context, if one exists. Otherwise, returns null.