Reputation: 1777
I'm trying to change the UserAccountsDrawerHeader background from light blue to another color in my Drawer but I'm not able to find a solution. Can anyone help me?
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:
Upvotes: 10
Views: 9972
Reputation: 5736
Since you've not specified the decoration
property, color is set to default primaryColor of theme. Use decoration
property to set color.
UserAccountsDrawerHeader(
decoration: BoxDecoration(
color: Colors.red,
),
accountName: Text(sessionUsername),
accountEmail: Text(mail),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.red,
backgroundImage: NetworkImage(gravatarUrl),
),
),
Upvotes: 27