我正在创建一个应用程序,我需要显示一个警告对话框.这不是一个可以容忍的对话.但是当我按下Android上的按钮时,它会被解雇.我尝试使用WillPopScope小部件来检测反压事件.我可以使用WillPopScope检测后退按钮按下但是在对话框打开时这不起作用.任何建议和指南都会非常有用.谢谢.
对话框创建代码段:
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),
),
],
);
});}
Run Code Online (Sandbox Code Playgroud)