![](/img/trans.png)
[英]Change background color for the action section in Flutter alertDialog
[英]how can I change the background color of the header using an alertDialog in flutter?
您可以使用 Container 作为title
。
AlertDialog
有一个titlePadding
属性。 如果title
不是 null,则默认值为 24。因此您需要显式地为其提供 0。
AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0)),
title: Container(
color: Colors.red,
child: Text('Error'),
),
titlePadding: const EdgeInsets.all(0),
)
您可以将标题包装在Container
中并将其与center
对齐。
试试这样的..
AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0)),
title: Container(
color: Colors.orange,
child: Center(
child: Text("Error"),
)),
titlePadding: const EdgeInsets.all(0),
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.