class _MyHomePageState extends State<MyHomePage> { String value = "1"; @override Widget build(BuildContext context) {return Scaffold(appBar: appBar (// navigation bar title: Text("Scaffold"), actions: <Widget>[// Navigation bar right menu IconButton(icon: icon (icon.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)) ) ], // initialValue: "1",// initial value // icon: icon (Icons.change_history), // icon padding: EdgeInsets. All (1),// inner margin is invalid child: Color: color.blue [200],fontSize: 20,),); }}Copy the code