首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >删除颤动警报对话框的灰色背景

删除颤动警报对话框的灰色背景
EN

Stack Overflow用户
提问于 2019-06-12 23:08:51
回答 3查看 8.3K关注 0票数 9

我的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();
                  }
                });
              }
            )
          ],
        )
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2019-06-13 03:37:44

只需使用de navigator启动对话框,而不是使用showDialog()并使用PageRouteBuilder

Navigator.of(context).push(
                  PageRouteBuilder(
                      pageBuilder: (context, _, __) => AlertDialog(),
                      opaque: false),
);
票数 5
EN

Stack Overflow用户

发布于 2020-08-23 05:11:17

部分解决这个问题的另一种解决方案是使用几乎透明的颜色作为屏障:

showDialog<void>(
      barrierColor: Color(0x01000000),
)
票数 11
EN

Stack Overflow用户

发布于 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);
    },
  );
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56565364

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档