Flutter navigation drawer hamburger icon color change

Navigation DrawerFlutterFlutter Layout

Navigation Drawer Problem Overview


Hamburger icon color of navigation drawer is not changing. Its black by default. I want to change the this icon color in flutter, I am stuck, help me to change this icon color. here is my code.

class Test extends StatefulWidget {
@override
_TestState createState() => new _TestState();
}

class _TestState extends State<Test> {
 

    @override
    Widget build(BuildContext context) {
    return new Scaffold(

    drawer: new Drawer(),
    appBar: new AppBar(
    title: new Text("Navigation Drawer")
        ),
       ),
     );
    }
 }

Navigation Drawer Solutions


Solution 1 - Navigation Drawer

Add iconTheme to your AppBar

@override
Widget build(BuildContext context) {
  return Scaffold(
    drawer: Drawer(),
    appBar: AppBar(
      title: Text("Navigation Drawer"),
      iconTheme: IconThemeData(color: Colors.green),
    ),
  );
}

You can also check other solutions here.

Solution 2 - Navigation Drawer

You can also use following in Theme's data property

Theme(
  data: ThemeData(primaryIconTheme: IconThemeData(color: Colors.red)), // use this
  child: Scaffold(),
)

Or

appBar: AppBar(
  leading: IconButton(
    icon: Icon(Icons.menu, color: Colors.red), // set your color here
    onPressed: () {},
  ),
),

Solution 3 - Navigation Drawer

> To change color of your icon use this

  @override
  Widget build(BuildContext context) {
   return new MaterialApp(
   home: new Scaffold(
    appBar: AppBar(title: new Text('List view example'),
      leading: new Icon(Icons.menu,color: Colors.green,),
   ),
),
 );
 }

> Icon(Icons.menu,color: Colors.green,) define color inside Icon

Solution 4 - Navigation Drawer

Use iconTheme in Appbar like this:

Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text("App Bar"),
          iconTheme: IconThemeData(color: Colors.black),
        ),
        drawer: Drawer(),
      );
}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAmmy KangView Question on Stackoverflow
Solution 1 - Navigation DrawerPhuc TranView Answer on Stackoverflow
Solution 2 - Navigation DrawerCopsOnRoadView Answer on Stackoverflow
Solution 3 - Navigation Drawerkishan vermaView Answer on Stackoverflow
Solution 4 - Navigation DrawerHarshil PatelView Answer on Stackoverflow