class _MyHomePageState extends State<MyHomePage> {
String value = "1";
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Scaffold"),
actions: <Widget>[
IconButton(icon: Icon(Icons.add_alarm), onPressed: () {}),
],
),
body: Center(
child: PopupMenuButton(
onSelected: (String selectValue){
setState(() {
value = selectValue;
});
},
itemBuilder: (BuildContext context) =><PopupMenuItem<String>>[
new PopupMenuItem(
value:"1",
child: new Text("11111111",style: TextStyle(color: value=="1"?Colors.red:Colors.grey))
),
new PopupMenuItem(
value: "2",
child: new Text("22222",style: TextStyle(color: value=="2"?Colors.red:Colors.grey))
)
],
padding: EdgeInsets.all(1),
child: Text("点击选择",style: TextStyle(backgroundColor: Colors.blue[200],fontSize: 20),),
),
),
);
}
}