我正在尝试将Drawer中的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:
答案 0 :(得分:0)
由于未指定decoration
属性,因此将颜色设置为主题的默认primaryColor。使用decoration
属性设置颜色。
UserAccountsDrawerHeader(
decoration: BoxDecoration(
color: Colors.red,
),
accountName: Text(sessionUsername),
accountEmail: Text(mail),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.red,
backgroundImage: NetworkImage(gravatarUrl),
),
),