gpt4 book ai didi

dart - 无法更改 UserAccountsDrawerHeader 背景

转载 作者:IT王子 更新时间:2023-10-29 07:12:10 38 4
gpt4 key购买 nike

我正在尝试将抽屉中的 UserAccountsDrawerHeader 背景从浅蓝色更改为另一种颜色,但我找不到解决方案。谁能帮帮我?

return Drawer(
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text(sessionUsername),
accountEmail: Text(mail),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.red,
backgroundImage: NetworkImage(gravatarUrl),
),
),
ListTile(
title: Text('Home'),
leading: Icon(Icons.home, color: myColor),
onTap: () {
print("Going to home");
//Close the drawer
Navigator.of(context).pop();
//Navigate to home page
//Navigate with avoiding the possibility to return
Navigator.of(context).pushReplacementNamed(HomePage.tag);
},
),

],
),
);

我的抽屉:

MyDrawer

最佳答案

由于您没有指定 decoration 属性,因此颜色设置为主题的默认 primaryColor。使用 decoration 属性设置颜色。

UserAccountsDrawerHeader(
decoration: BoxDecoration(
color: Colors.red,
),
accountName: Text(sessionUsername),
accountEmail: Text(mail),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.red,
backgroundImage: NetworkImage(gravatarUrl),
),
),

关于dart - 无法更改 UserAccountsDrawerHeader 背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55420478/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com