Flutter PopupMenuButton使用

效果:

Flutter PopupMenuButton使用_第1张图片

常用属性

  const PopupMenuButton({
    Key key,
    @required this.itemBuilder,//item构建
    this.initialValue,//默认值
    this.onSelected,//选中回调
    this.onCanceled,//取消回调
    this.tooltip,//长按提示信息
    this.elevation = 8.0,//阴影
    this.padding = const EdgeInsets.all(8.0),//padding
    this.child,//子widget
    this.icon,//图标,与child存在其一
    this.offset = Offset.zero,//默认zero即Offset(0.0,0.0),当值大于100的时候就会显示在AppBar的下面,Offset(100, 100)
  }) 

示例代码

PopupMenuButton(
                icon: Icon(Icons.more_horiz),
                offset: Offset(100, 100),
                itemBuilder: (BuildContext context) => >[
                      const

你可能感兴趣的:(Flutter,Flutter,开发实战)