颤动更改对话框背景色 [英] Flutter change dialog background color

查看:53
本文介绍了颤动更改对话框背景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 dialogBackgroundColor 属性,但颜色没有改变.谁能告诉我如何更改对话框的背景颜色?

I was using dialogBackgroundColor property still the color was not changing. Can anyone tell me how to change the background color of the dialog?

推荐答案

您需要像这样将 Dialog 包装在 Builder 中.之后, dialogBackgroundColor 将生效.

You need to wrap your Dialog in a Builder like this. After that dialogBackgroundColor will have an effect.

Theme(
  data: ThemeData(dialogBackgroundColor: Colors.orange),
  child: Builder(
    builder: (context) {
      return RaisedButton(
        onPressed: () {
          showDialog(
            context: context,
            builder: (context) {
              return AlertDialog(
                title: Text("Dialog title"),
              );
            },
          );
        },
        child: Text("Show dialog"),
      );
    },
  ),
)

这篇关于颤动更改对话框背景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆