小编SIL*_*NCE的帖子

如何更改 CupertinoAlertDialog 的背景颜色?

我想创建一个带有深色背景的 CupertinoAlertDialog。

我尝试使用 Theme 小部件来解决这个问题,但它不起作用。

这里的一些代码:

showDialog() {
    showCupertinoDialog(
        context: context,
        builder: (context) {
          return Theme(
            data: ThemeData(
                dialogBackgroundColor: Colors.black,
                dialogTheme: DialogTheme(backgroundColor: Colors.black)),
            child: CupertinoAlertDialog(
            title: Text('Title'),
            content: Text('Some message here'),
            actions: <Widget>[
               FlatButton(
                 onPressed: () {
                   Navigator.of(context).pop();
                 },
                 child: Text('OK'),
               ),
             ],
           ),
         );
       },
     );
  }
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

dialog flutter

6
推荐指数
2
解决办法
3449
查看次数

标签 统计

dialog ×1

flutter ×1