Here is my PopupMenuButton
PopupMenuButton(
icon:
Icon(Icons.more_vert, color: Colors.white),
itemBuilder: (context) => [
PopupMenuItem(
onTap: () {
showMyDialog();
},
child: Text(
"Edit Profile Picture",
style: TextStyle(
color: AppColors.pinkColor),
),
value: 1,
),
PopupMenuItem(
child: Text(
"Edit Cover Picture",
style: TextStyle(
color: AppColors.pinkColor),
),
value: 2,
),
PopupMenuItem(
child: Text(
"Setting",
style: TextStyle(
color: AppColors.pinkColor),
),
value: 3,
)
])
And this is my Dilaogue function
Future<void> _showMyDialog() async {
return showDialog<void>(
context: context,
barrierDismissible: false, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: const Text('AlertDialog Title'),
content: SingleChildScrollView(
child: ListBody(
children: const <Widget>[
Text('This is a demo alert dialog.'),
Text('Would you like to approve of this message?'),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Approve'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
);
},
);
}
_showMyDialog()
and your call saysshowMyDialog()
without_
. Try to call it as you declared the function.