RemixMenu<T> class

An overlay menu configured with trigger and item data. All styling is centralized in MenuStyler and passed directly to children.

Example

// Simple usage - controller created automatically
RemixMenu<String>(
  trigger: RemixMenuTrigger(label: 'Options', icon: Icons.more_vert),
  items: <RemixMenuItemData<String>>[
    RemixMenuItem(value: 'copy', label: 'Copy', leadingIcon: Icons.copy),
    RemixMenuItem(value: 'paste', label: 'Paste', leadingIcon: Icons.paste),
    RemixMenuDivider(),
    RemixMenuItem(value: 'delete', label: 'Delete', leadingIcon: Icons.delete),
  ],
  onSelected: (value) => debugPrint('Selected: $value'),
)

// Advanced usage - provide controller for programmatic control
final menuController = MenuController();
RemixMenu<String>(
  controller: menuController,
  trigger: RemixMenuTrigger(label: 'Options'),
  items: [...],
  onSelected: (value) => debugPrint(value),
)

// Custom visual content — builder output must not be a nested button
RemixMenu<String>(
  trigger: RemixMenuTrigger.builder(
    label: 'Account menu',
    builder: (context, state, defaultTrigger) => const Text('LF'),
  ),
  items: [...],
)

// A real button as the trigger
RemixMenu<String>(
  trigger: RemixMenuTrigger.control(
    builder: (context, menu) => RemixButton(
      label: 'Actions',
      focusNode: menu.focusNode,
      onPressed: menu.toggle,
    ),
  ),
  items: [...],
)
Inheritance

Constructors

RemixMenu({Key? key, required RemixMenuTrigger trigger, required List<RemixMenuItemData<T>> items, MenuController? controller, ValueChanged<T>? onSelected, VoidCallback? onOpen, VoidCallback? onClose, VoidCallback? onCanceled, RawMenuAnchorOpenRequestedCallback? onOpenRequested, RawMenuAnchorCloseRequestedCallback? onCloseRequested, bool consumeOutsideTaps = true, bool useRootOverlay = false, bool closeOnClickOutside = true, FocusNode? triggerFocusNode, OverlayPositionConfig positioning = const OverlayPositionConfig(), String? semanticLabel, bool excludeSemantics = false, MenuStyler style = const MenuStyler.create(), MenuSpec? styleSpec})
const

Properties

closeOnClickOutside → bool
Whether taps outside the overlay close the menu.
final
consumeOutsideTaps → bool
Whether outside taps on the trigger are consumed.
final
controller → MenuController?
Optional controller for programmatic control of the menu state. If not provided, an internal controller will be created automatically.
final
excludeSemantics → bool
Whether to hide the menu trigger from the semantic tree.
final
hashCode → int
The hash code for this object.
no setterinherited
items → List<RemixMenuItemData<T>>
The declarative ordinary, compound, submenu, and divider data.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onCanceled → VoidCallback?
Called when the menu closes without a selection.
final
onClose → VoidCallback?
Called when the menu closes.
final
onCloseRequested → RawMenuAnchorCloseRequestedCallback?
final
onOpen → VoidCallback?
Called when the menu opens.
final
onOpenRequested → RawMenuAnchorOpenRequestedCallback?
Open/close interceptors (for example, to drive animations).
final
onSelected → ValueChanged<T>?
Called when an item is selected.
final
positioning → OverlayPositionConfig
Overlay positioning configuration.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticLabel → String?
The semantic label for the menu trigger.
final
style → MenuStyler
The style configuration for the menu.
final
styleSpec → MenuSpec?
Optional raw style spec that bypasses fluent style resolution.
final
trigger → RemixMenuTrigger
Trigger configuration for the menu's button.
final
triggerFocusNode → FocusNode?
Optional focus node for the trigger.
final
useRootOverlay → bool
Whether to target the root overlay instead of the nearest ancestor.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<RemixMenu<T>>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

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

Static Properties

styleFrom → MenuStyler Function({AnimationConfig? animation, MenuItemStyler? checkboxItem, RemixBoxEffectsMix? containerEffects, DividerStyler? divider, MenuItemStyler? item, WidgetModifierConfig? modifier, FlexBoxStyler? overlay, MenuItemStyler? radioItem, MenuItemStyler? submenuItem, MenuTriggerStyler? trigger, List<VariantStyle<MenuSpec>>? variants})
final