我在Flutter 中创建应用程序,需要在其中显示警告对话框.而且这不是一个不可忽视的对话.但当我在Android上按下后退按钮时,它被关闭了.我已经try 使用WillPopScope小部件来检测背压事件.我可以使用WillPopScope检测到按下Back按钮,但在对话框打开时这不起作用.任何建议和指南都会很有帮助.谢谢.
对话框创建代码段:
void buildMaterialDialog(
String dialogTitle,
String dialogContent,
String negativeBtnText,
String positiveBtnText,
String positiveTextUri) {
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return new AlertDialog(
title: new Text(dialogTitle),
content: new Text(dialogContent),
actions: <Widget>[
new FlatButton(
onPressed: () {
//Function called
_updateDialogNegBtnClicked(isCancelable);
},
child: new Text(negativeBtnText),
),
new FlatButton(
onPressed: () => launch(positiveTextUri),
child: new Text(positiveBtnText),
),
],
);
});}