Dart 无法更改UserAccountsDrawerHeader后台

Dart 无法更改UserAccountsDrawerHeader后台,dart,flutter,Dart,Flutter,我正在尝试将UserAccountsDrawerHeader背景从浅蓝色更改为抽屉中的另一种颜色,但我无法找到解决方案。有人能帮我吗 return Drawer( child: ListView( // Important: Remove any padding from the ListView. padding: EdgeInsets.zero, children: <Widget>[ UserAccountsDrawerHeader(

我正在尝试将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);
        },
      ),

    ],
  ),
);
返回抽屉(
子:ListView(
//重要提示:从ListView中删除任何填充。
填充:EdgeInsets.zero,
儿童:[
UserAccountsDrawerHeader(
accountName:文本(sessionUsername),
帐户电子邮件:文本(邮件),
currentAccountPicture:CircleAvatar(
背景颜色:Colors.red,
背景图片:NetworkImage(gravatarUrl),
),
),
列表砖(
标题:文本(“主页”),
前导:图标(Icons.home,颜色:myColor),
onTap:(){
打印(“回家”);
//关上抽屉
Navigator.of(context.pop();
//导航到主页
//避免返回的可能性
Navigator.of(context.pushReplacementNamed(HomePage.tag);
},
),
],
),
);
我的抽屉:


由于您尚未指定
装饰
属性,因此颜色设置为主题的默认primaryColor。使用
装饰
属性设置颜色

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