Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Drawer Icon Color Flutter

Tags:

flutter

dart

I have a white AppBar color, and when I add a AppDrawer into the icon for the drawer gets blended in with the white AppBar. How do I change the coloring of the icon for the drawer?

Here is some of my code:

@override
  Widget build(BuildContext context) {
    return Scaffold(
      endDrawer: AppDrawer(),
      appBar: AppBar(
        backgroundColor: Colors.white,
        title: Image.asset(
          'images/appbar_logo.jpg',
          fit: BoxFit.fill,
        ),
        centerTitle: true,
      ), // AppBar

and my AppDrawer stateful widget:

class AppDrawer extends StatefulWidget {
  @override
  _AppDrawerState createState() => _AppDrawerState();
}

class _AppDrawerState extends State<AppDrawer> {
  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: ListView(
        children: <Widget>[
          new DrawerHeader(
              child: new Image.asset("images/drawer_header_img.jpg")),
          ListTile(
            title: new Text("Item 1"),
          ),
          ListTile(
            title: new Text("Item 2"),
          ),
        ],
      ),
    );
  }
like image 296
HDiamond Avatar asked Aug 02 '18 16:08

HDiamond


People also ask

How do you change the icon drawer color in Flutter?

To change the drawer icon color in Flutter: Simply add the iconTheme property inside the AppBar widget and assign the IconThemeData(color: [your_color]).


1 Answers

Add iconTheme property to appBar

@override
Widget build(BuildContext context) {
return Scaffold(
  endDrawer: AppDrawer(),
  appBar: AppBar(
    backgroundColor: Colors.white,
    title: Image.asset(
      'images/appbar_logo.jpg',
      fit: BoxFit.fill,
    ),
    centerTitle: true,
    iconTheme: IconThemeData(color: Colors.blue), //add this line here
  ), // AppBar

Ref: doc

like image 166
Felix Runye Avatar answered Oct 01 '22 05:10

Felix Runye