我的Flutter应用程序中有一个CupertinoAlertDialog和AlertDialog。每次弹出对话框时,它后面的一切都会变暗。我想把背景去掉。我该怎么做?
CupertinoDialogAction(
child: Text('Delete',
style: TextStyle(color: Colors.red),
),
onPressed: () async {
await CommentActivity.delete(postData[index]['id'])
.then((response) {
if (response) {
setState(() {
postData.removeAt(index);
createPageActivity();
renderPageActivity();
});
Navigator.of(context).pop();
}
});
}
)
],
)
发布于 2019-06-13 03:37:44
只需使用de navigator启动对话框,而不是使用showDialog()并使用PageRouteBuilder
Navigator.of(context).push(
PageRouteBuilder(
pageBuilder: (context, _, __) => AlertDialog(),
opaque: false),
);
发布于 2020-08-23 05:11:17
部分解决这个问题的另一种解决方案是使用几乎透明的颜色作为屏障:
showDialog<void>(
barrierColor: Color(0x01000000),
)
发布于 2020-10-06 15:37:55
showDialog方法中具有barrierColor属性的简单解决方案,我将白色设置为不透明度值为零,并且遮挡阴影消失
AlertDialog alert = AlertDialog(
backgroundColor: Colors.transparent,
elevation: 0,
content: new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Loader(),
],
),
);
showDialog(
barrierColor: Colors.white.withOpacity(0),
barrierDismissible: false,
context: context,
builder: (BuildContext context) {
return WillPopScope(
onWillPop: (){},
child: alert);
},
);
https://stackoverflow.com/questions/56565364
复制相似问题