如何使PopupMenuItem根据标签栏中标签的变化而变化?像WhatsApp。
include appbar actions:
actions: [
IconButton(
onPressed: () {},
icon: Icon(Icons.camera_alt_outlined)),
IconButton(onPressed: () {}, icon: Icon(Icons.search)),
PopupMenuButton(
// add icon, by default "3 dot" icon
// icon: Icon(Icons.book)
itemBuilder: (context) {
var mypop = DefaultTabController.of(context) !.index;
if (mypop == 0) {
return [
PopupMenuItem < int > (
padding: EdgeInsets.only(left: 10, right: 50),
height: 30,
child: Text("Settings"),
),
];
} else if (mypop == 1) {
return [
PopupMenuItem < int > (
child: Text("New group"),
),
PopupMenuItem < int > (
child: Text("New broadcast"),
),
PopupMenuItem < int > (
child: Text("Starred messages"),
),
PopupMenuItem < int > (
child: Text("Payments"),
),
PopupMenuItem < int > (
child: Text("Settings"),
),
];
} else if (mypop == 2) {
return [
PopupMenuItem < int > (
child: Text("Status privacy"),
),
PopupMenuItem < int > (
child: Text("Settings"),
),
];
} else if (mypop == 3) {
return [
PopupMenuItem < int > (
child: Text("Clear call log"),
),
PopupMenuItem < int > (
child: Text("Settings"),
),
];
}
return [];
}),
],