Flutter :- 带有背景颜色的自定义 showDialog

Edu*_*lez 3 flutter

在此输入图像描述

  void _showDialog(BuildContext context) {
    showDialog(
      context: context,
      builder: (BuildContext context) {  
        return AlertDialog(
          title: new Text("Alert Dialog title"),
          content: new Text("Alert Dialog body"),
          actions: <Widget>[
            // usually buttons at the bottom of the dialog
            new FlatButton(
              child: new Text("Close"),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }
Run Code Online (Sandbox Code Playgroud)

我需要创建这个事件,在显示对话窗口的那一刻,屏幕的其他部分改变颜色,我在咨询其他来源时遇到了麻烦,事实是我无法与该事件重合。

目标是实现这样的目标:

在此输入图像描述

men*_*gdi 6

只需将barrierColor参数传递给showDialog

showDialog(
  context: context,
  barrierColor: Color(0x640000FF),
  builder: (BuildContext context) {  
    return AlertDialog(
      // ...
    );
  },
);
Run Code Online (Sandbox Code Playgroud)