![](/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.