-
Notifications
You must be signed in to change notification settings - Fork 27.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Change background color of UserAccountsDrawerHeader in Drawer. #26164
Comments
Can you please post complete runnable code so that copy/paste is enough to run? Please consider asking support questions in one of the other channels listed at http://flutter.io/support . |
Hi Gunter, I think i found a workaround for the issue but don't know if its good. ALSO now there is very very thin divider line below the UserAccout box and primarycolorbrightness does not get override using copywith. Please see complete working code main.dart. I have put in comments for your reference. Thanks ### MAIN.DART import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
canvasColor: Colors.white,
primaryColor: Colors
.red, //**this is to check is overide works in drawer theme. */
primaryColorBrightness:
Brightness.dark, /** unable to overide in drawer theme */
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
SystemChrome.restoreSystemUIOverlays();
return Scaffold(
appBar: AppBar(
//Makes visible status bar txt and icon in ios.
brightness: Brightness.light,
elevation: 0.0,
backgroundColor: Colors.transparent, //APP BAR TRANSPARENT
iconTheme: new IconThemeData(color: Colors.black), //DRAWER ICON COLOR
),
drawer: Theme(
data: Theme.of(context).copyWith(
canvasColor: Colors.transparent,
primaryColor: Colors.transparent, //***PRIMARY COLOR overide works */
//** */DOES NOT OVERRIDE THEMEDATA IN MATERIALAPP***
primaryColorBrightness: Brightness.light,
),
child: Drawer(
child: (ListView(
padding: EdgeInsets.zero,
children: <Widget>[
new Container(
padding: EdgeInsets.only(top: 100),
color: Colors.transparent,
child: UserAccountsDrawerHeader(
currentAccountPicture: CircleAvatar(
backgroundColor: Color.fromRGBO(255, 244, 200, 0.1)),
accountName: Text('NAME'),
accountEmail: Text('XYZ@gmail.com'),
),
),
ListTile(
title: Text('Item 1'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
title: Text('Item 2'),
onTap: () {
// Update the state of the app
// ...
// Then close the drawer
Navigator.pop(context);
},
),
],
)),
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.display1,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
} |
This sounds like #14288 |
/cc @HansMuller who may have thoughts. Agreed with @zoechi re: the divider line. |
Hi @saltpetreca, can you please confirm if you still experience this issue with latest Flutter version (eg: dev, master)?
Using above snippet and the code sample you provided, I was able to see the If you confirm that this is no longer an issue and works as intended, you may close this ticket. |
Without additional information we are unfortunately not sure how to resolve this issue. Could everyone who still has this problem please file a new issue with the exact description of what happens, logs and the output of |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to Reproduce
Goal: Have a transparent drawer including the
UserAccountDrawerHeader
.Unable to change color of
UserAccountsDrawerHeader
in Drawer to transparent.Able to change
DrawerHeader
color to transparent using container. But that workaround does not work forUserAccountsDrawerHeader
.Below code for
UserAccountDrawerHeader
. (Using red to represent as transparent is not visible.)**Below code using
DrawerHeader
and able to get transparent background using containerBut unable to get the same effect, arrangement and ease of
UserAccountDrawerHeader
**
flutter doctor -v
The text was updated successfully, but these errors were encountered: