Flutter之PopupMenuButton
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,
})
@override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter', theme: ThemeData( primarySwatch: Colors.blue, ), home: Scaffold( appBar: AppBar( leading: IconButton( icon: new Container( child: new Icon(Icons.arrow_back), ), onPressed: () { Navigator.pop(context); }), title: Text("登陆(Login)"), centerTitle: true, actions: <Widget>[ new PopupMenuButton( itemBuilder: (BuildContext context) { return <PopupMenuItem<String>>[ PopupMenuItem<String>( child: Text("分享"), value: "share", ), PopupMenuItem<String>( child: Text("更多"), value: "more", ), ]; }, onSelected: (String action) { switch (action) { case "share": print("分享 QQ、微信"); break; case "more": print("更多"); break; } }, ), ]), body: Center( child: LoginPage(), )), ); } }