Flutter导航抽屉汉堡包图标变色

Flutter navigation drawer hamburger icon color change

导航抽屉的汉堡图标颜色没有改变。默认为黑色。我想在 flutter 中更改此图标颜色,我卡住了,帮我更改此图标颜色。这是我的代码。

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

iconTheme 添加到您的 AppBar

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

您还可以检查other solutions here.

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

您还可以在 Themedata 属性

中使用以下内容
Theme(
  data: ThemeData(primaryIconTheme: IconThemeData(color: Colors.red)), // use this
  child: Scaffold(),
)

或者

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

像这样在 Appbar 中使用 iconTheme

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