Search code examples
navigation-drawerflutterflutter-layout

Flutter navigation drawer hamburger icon color change


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

Solution

  • The iconTheme property of the AppBar widget is used to specify the styling for the leading icon, which is typically the menu icon.

    By setting IconThemeData(color: Colors.green), the color of the leading icon in the app bar is changed to green.

    @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.