Flutter navigation drawer hamburger icon color cha

2020-05-30 03:49发布

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

3条回答
Explosion°爆炸
2楼-- · 2020-05-30 04:02

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: () {},
  ),
),
查看更多
Juvenile、少年°
3楼-- · 2020-05-30 04:10

Add iconTheme to your AppBar

@override
Widget build(BuildContext context) {
  return new Scaffold(
    drawer: new Drawer(),
    appBar: new AppBar(
      title: new Text("Navigation Drawer"),
      iconTheme: new IconThemeData(color: Colors.green),
    ),
  );
}
查看更多
狗以群分
4楼-- · 2020-05-30 04:20

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

查看更多
登录 后发表回答