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
-
- Object
- ContextMenuEntry
- ContextMenuItem
- Implementers
Constructors
- ContextMenuItem({T? value, VoidCallback? onSelected})
-
const
-
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
-
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, 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, ) → void -
Called when the mouse pointer enters the area of the context menu entry.
inherited
-
onMouseExit(
PointerExitEvent event, ) → void -
Called when the mouse pointer exits the area of the context menu entry.
inherited
-
onMouseHover(
PointerHoverEvent event, ) → 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