美文网首页flutter
Flutter之PopupMenuButton组件

Flutter之PopupMenuButton组件

作者: 习惯了_就好 | 来源:发表于2018-11-30 15:08 被阅读144次
    /**
        const PopupMenuButton({
        Key key,
        @required this.itemBuilder,
        this.initialValue,//初始值,如果itemBuilder里该值,则会高亮显示
        this.onSelected,//选中弹出弹出选项的回调
        this.onCanceled,//点屏幕外取消回调,点击屏幕其他地方时调用
        this.tooltip,//
        this.elevation = 8.0,//
        this.padding = const EdgeInsets.all(8.0),
        this.child,//修改PopupMenuButton默认三个点的图标为设置的child,不能与icon同时使用
        this.icon,//修改PopupMenuButton默认三个点的图标为设置的icon,不能与child同时使用
        this.offset = Offset.zero,
        })
     */
    
    body: Container(
              child: Center(
                child: PopupMenuButton(
    //              icon: Icon(Icons.home),
                  child: Text("abc"),
                  tooltip: "长按提示",
                  initialValue: "hot",
                  padding: EdgeInsets.all(0.0),
                  itemBuilder: (BuildContext context) {
                    return <PopupMenuItem<String>>[
                      PopupMenuItem<String>(child: Text("热度"), value: "hot",),
                      PopupMenuItem<String>(child: Text("最新"), value: "new",),
                    ];
                  },
                  onSelected: (String action) {
                    switch (action) {
                      case "hot":
                        print("热度");
                        break;
                      case "new":
                        print("最新");
                        break;
                    }
                  },
                  onCanceled: () {
                    print("onCanceled");
                  },
                ),
              ),
            ),
    

    相关文章

      网友评论

        本文标题:Flutter之PopupMenuButton组件

        本文链接:https://www.haomeiwen.com/subject/xmjhcqtx.html