-
PopupMenuButton:菜单按钮组件,点击后弹出PopupMenuItem,PopupMenuDivider设置分割线,空间前带选中的使用CheckedPopupMenuItem、
-
showMenu:显示Menu方法,跟onPressed连用
2.1 源码
const PopupMenuButton({
Key? key,
required this.itemBuilder,
this.initialValue,
this.onSelected,
this.onCanceled,
this.tooltip,
this.elevation,
this.padding = const EdgeInsets.all(8.0),
this.child,
this.icon,
this.iconSize,
this.offset = Offset.zero,
this.enabled = true,
this.shape,
this.color,
this.enableFeedback,
})
2.2 属性说明
| 属性 | 说明 | 取值 |
| :-: | :-: | :-: |
| initialValue | 初始值 | T |
| onSelected | 选中调用 | Function(T value) |
| onCanceled | 取消选中 | Function() |
| tooltip | 长按时显示文本 | String |
| child | menu控件 | Widget |
| icon | menu图标 | Widget |
| iconSize | 图标大小 | double |
| offset | 菜单弹出的位置 | Offset |
| shape | 弹出菜单边框 | ShapeBorder |
| color | 弹出菜单颜色 | Color |