CupertinoContextMenu class Null safety

A full-screen modal route that opens when the child is long-pressed.

When open, the CupertinoContextMenu shows the child, or the widget returned by previewBuilder if given, in a large full-screen Overlay with a list of buttons specified by actions. The child/preview is placed in an Expanded widget so that it will grow to fill the Overlay if its size is unconstrained.

When closed, the CupertinoContextMenu simply displays the child as if the CupertinoContextMenu were not there. Sizing and positioning is unaffected. The menu can be closed like other PopupRoutes, such as by tapping the background or by calling Navigator.pop(context). Unlike PopupRoute, it can also be closed by swiping downwards.

The previewBuilder parameter is most commonly used to display a slight variation of child. See previewBuilder for an example of rounding the child's corners and allowing its aspect ratio to expand, similar to the Photos app on iOS.

This sample shows a very simple CupertinoContextMenu for an empty red 100x100 Container. Simply long press on it to open.
To create a local project with this code sample, run:
flutter create --sample=cupertino.CupertinoContextMenu.1 mysample

See also:

Inheritance

Constructors

CupertinoContextMenu({Key? key, required List<Widget> actions, required Widget child, ContextMenuPreviewBuilder? previewBuilder})
Create a context menu.

Properties

actions List<Widget>
The actions that are shown in the menu.
final
child Widget
The widget that can be "opened" with the CupertinoContextMenu.
final
hashCode int
The hash code for this object.
nonVirtual">@nonVirtualread-onlyinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
previewBuilder ContextMenuPreviewBuilder?
A function that returns an alternative widget to show when the CupertinoContextMenu is open.
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<CupertinoContextMenu>
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.
protected">@protectedinherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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}) 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.
nonVirtual">@nonVirtualinherited