Flutter 如何使用颤振中的alertDialog更改标题的背景色?
当前,仅文本仅使用以下代码绘制Flutter 如何使用颤振中的alertDialog更改标题的背景色?,flutter,Flutter,当前,仅文本仅使用以下代码绘制 我想用一种颜色绘制alertDialog的标题,我该怎么做?您可以使用容器作为标题 AlertDialog有一个标题adding属性。如果title不为空,则默认值为24。因此,您需要显式地为其提供0 AlertDialog( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(20.0)), title: Container( color: Colors.
我想用一种颜色绘制alertDialog的标题,我该怎么做?您可以使用容器作为
标题
AlertDialog
有一个标题adding
属性。如果title
不为空,则默认值为24。因此,您需要显式地为其提供0
AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0)),
title: Container(
color: Colors.red,
child: Text('Error'),
),
titlePadding: const EdgeInsets.all(0),
)
您可以将标题包装在容器中
并将其与中心对齐
试试这样的
AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0)),
title: Container(
color: Colors.orange,
child: Center(
child: Text("Error"),
)),
titlePadding: const EdgeInsets.all(0),
)
你试着把一行作为标题吗?然后,您可以在该行中放置一个展开的,它将占用整个空间。然后给扩展的小部件上色。我试过了,但无法绘制整个标题。谢谢,但是我遇到了这个问题:我试着问的是试着画整个标题,也就是说,从顶部边缘到标题所在的位置,你的完整代码是什么,我的看起来很好谢谢你的帮助。。。我不知道我做错了什么,但是现在由于某种原因顶部的圆形边缘丢失了,你知道为什么吗?可能与FadeInDown
小部件有关
AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0)),
title: Container(
color: Colors.orange,
child: Center(
child: Text("Error"),
)),
titlePadding: const EdgeInsets.all(0),
)