ComPopupMenu class

弹出菜单组件

一个功能丰富的弹出菜单组件,支持自定义触发方式、位置和样式。 具有智能位置计算、无障碍支持和优化的性能。

参数说明:

Inheritance

Constructors

ComPopupMenu.new({Key? key, required Widget child, required Widget? menuBuilder, PressType pressType = PressType.singleClick, ComPopupMenuController? controller, Color? arrowColor, bool showArrow = true, Color barrierColor = Colors.black12, double arrowSize = 14.0, double horizontalMargin = 16.0, double verticalMargin = 4.0, PreferredPosition? position, void menuOnChange(bool)?, bool enablePassEvent = true, String? semanticLabel, bool excludeFromSemantics = false})
const

Properties

arrowColor Color?
箭头颜色
final
arrowSize double
箭头大小
final
barrierColor Color
遮罩层颜色
final
child Widget
触发菜单的子组件
final
controller ComPopupMenuController?
控制器
final
enablePassEvent bool
是否允许点击事件穿透到下层组件 仅在 barrierColor 为透明时有效
final
excludeFromSemantics bool
是否从语义树中排除
final
hashCode int
The hash code for this object.
no setterinherited
horizontalMargin double
水平边距
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
菜单内容构建器
final
菜单状态变化回调
final
position PreferredPosition?
首选位置
final
pressType PressType
触发方式
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
semanticLabel String?
语义化标签
final
showArrow bool
是否显示箭头
final
verticalMargin double
垂直边距
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() ComPopupMenuState
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 Methods

options({Key? key, required Widget child, required List<PopupMenuOption> options, Color? backgroundColor, BorderRadius? borderRadius, double? width, PressType pressType = PressType.singleClick, ComPopupMenuController? controller, PreferredPosition? position, bool showArrow = true, Color? arrowColor, void onMenuChanged(bool)?}) ComPopupMenu
创建一个包含多个选项的菜单
text({Key? key, required Widget child, required String text, TextStyle? textStyle, EdgeInsets? padding, Color? backgroundColor, BorderRadius? borderRadius, double? width, PressType pressType = PressType.singleClick, ComPopupMenuController? controller, PreferredPosition? position, bool showArrow = true, Color? arrowColor, void onMenuChanged(bool)?}) ComPopupMenu
创建一个简单的文本菜单