HDiamond
HDiamond

Reputation: 1097

Changing Drawer Icon Color Flutter

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"),
          ),
        ],
      ),
    );
  }

Upvotes: 7

Views: 11486

Answers (1)

Felix Runye
Felix Runye

Reputation: 2521

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

Upvotes: 8

Related Questions