ContextMenuItem<T> class abstract base

Represents a selectable item in a context menu.

The ContextMenuItem class is used to define individual items that can be displayed within a context menu. It extends the ContextMenuEntry class, providing additional functionality for handling item selection, submenus, and associated values.

A ContextMenuItem can have an associated value that can be returned when the item is selected. It can also contain a list of items to represent submenus, enabling a hierarchical structure within the context menu.

When a ContextMenuItem is selected, it triggers the handleItemSelection method, which determines whether the item has subitems. If it does, it toggles the visibility of the submenu associated with the item. If not, it pops the current context menu and returns the associated value.

Parameters:

  • value - The value associated with the context menu item.
  • items - The list of subitems associated with the context menu item.
  • onSelected - The callback that is triggered when the context menu item is selected.

see:

Inheritance
Implementers

Constructors

ContextMenuItem({T? value, VoidCallback? onSelected})
const
ContextMenuItem.submenu({required List<ContextMenuEntry>? items, VoidCallback? onSelected})
const

Properties

debugLabel String
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
isFocusMaintained bool
Indicates whether the menu item is using the focus node in a child widget.
no setter
isSubmenuItem bool
Indicates whether the menu item has subitems.
no setter
items List<ContextMenuEntry>?
final
onSelected VoidCallback?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T?
final

Methods

builder(BuildContext context, ContextMenuState menuState, [FocusNode focusNode]) Widget
Builds the widget representation of the context menu entry.
override
handleItemSelection(BuildContext context) → void
Handles the selection of the context menu item.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onMouseEnter(PointerEnterEvent event, ContextMenuState menuState) → void
Called when the mouse pointer enters the area of the context menu entry.
inherited
onMouseExit(PointerExitEvent event, ContextMenuState menuState) → void
Called when the mouse pointer exits the area of the context menu entry.
inherited
onMouseHover(PointerHoverEvent event, ContextMenuState menuState) → void
Called when the mouse pointer hovers over the context menu entry.
inherited
toString() String
A string representation of this object.
inherited

Operators

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