DesignContextMenu class
A menu of menuChildren that opens over child, where the user asks for it.
- A right click (a secondary tap: a two-finger click on a trackpad) opens it at the pointer, and so does a long press of a finger or a stylus, with the long press's haptic (DesignHaptics.longPress) when enableFeedback. The menu opens below the point from its start in reading order, above it or towards its other end where there is no room, and never under it. No row is lit until the pointer or a key picks one.
- Shift+F10, or the Menu key, opens it at the focused widget's leading bottom corner, while the focus is inside child, its first row lit.
- A screen reader finds "Show menu" (DesignLocalizations.showMenuTooltip) among the region's actions, and a long press (Android's double tap and hold) says it.
- On the web, the browser's own menu stays shut while a pointer is over the region or pressed in it, focus is in it, or its menu is open; it works as before elsewhere, and an app that turned it off itself keeps it off.
- A context menu inside another's region opens alone: the innermost wins.
Escape, a tap outside it or Android's back closes it, and the focus goes back to where it was. A command closes it, then runs.
DesignContextMenu(menuChildren: [DesignMenuEntry(label: 'Copy', onPressed: () {})], itemBuilder: (context, entry, level, states) => Text(entry.label), surfaceBuilder: (context, info, items) => Column(mainAxisSize: MainAxisSize.min, children: items), child: const Text('Report.pdf'))
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- DesignContextMenu
Constructors
-
DesignContextMenu({Key? key, required DesignMenuItemBuilder itemBuilder, required DesignMenuSurfaceBuilder surfaceBuilder, required Widget child, WidgetBuilder? dividerBuilder, MenuController? controller, ValueChanged<
bool> ? onOpenChanged, String? semanticLabel, bool highlightFollowsPointer = true, bool enableFeedback = true, bool useRootOverlay = false, double dampingRatio = 1, double stiffness = 1400}) -
A menu of
menuChildrenoverchild.const
Properties
- child → Widget
-
The region that opens it.
final
- controller → MenuController?
-
Opens it at a point of child from outside (
open(position:)) and closes it; null: it makes its own. The caller disposes nothing: a MenuController holds no resources.final - dampingRatio → double
-
The open and close spring's damping ratio (
DesignMotion); 1 by default, critically damped.final - dividerBuilder → WidgetBuilder?
-
Paints a divider; null: a 1 px gap.
final
- enableFeedback → bool
-
Whether a long press that opens it plays DesignHaptics.longPress;
true by default.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- highlightFollowsPointer → bool
-
Whether a pointer over a row moves the keys there; true by default, as
DesignMenuBar.highlightFollowsPointer.
final
- itemBuilder → DesignMenuItemBuilder
-
Paints a row (DesignMenuLevel.menu).
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
The menu's rows: commands, submenus and dividers. Empty: no menu, no
action for a screen reader, and the browser's own menu on the web.
final
-
onOpenChanged
→ ValueChanged<
bool> ? -
Told when it opens (true) and when it has closed (false).
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- semanticLabel → String?
-
What a screen reader calls the menu; null: none.
final
- stiffness → double
-
The open and close spring's stiffness; 1400 by default.
final
- surfaceBuilder → DesignMenuSurfaceBuilder
-
Paints the menu's panel round its rows (scroll them when
DesignOverlayInfo.maxSize is short). DesignOverlayInfo.position is
the point it opened at.
final
- useRootOverlay → bool
-
Whether it opens in the root overlay, over every navigator; false by
default: the nearest overlay.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< DesignContextMenu> -
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.
override
-
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