如何使PopupMenuItems根据标签栏中的标签改变,如WhatsApp



如何使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 [];
}),
],

相关内容

  • 没有找到相关文章

最新更新