I am not able to get showDialog
work with PopupMenuButton
. In the example below, there is a button with triggering a dialog to display and a popupmenu too triggering a dialog to display.
The button works but on clicking on the Alert text in PopupMenu, the same doesn't happen.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('showDialog bug'), actions: [
PopupMenuButton(
itemBuilder: (ctx) => [
PopupMenuItem(
child: Text('Alert'),
onTap: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('test dialog'),
));
})
])
]),
body: ElevatedButton(
onPressed: () {
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('test dialog'),
));
},
child: Text('click me')));
}
}
However, when I add another block of showDialog
subsequent to it, it starts working.
showDialog(
context: context,
builder: (ctx) => AlertDialog(
title: Text('test dialog'),
));