How to add icon to AppBar in Flutter

六月ゝ 毕业季﹏ 提交于 2019-12-13 09:50:04

问题


If I have an AppBar like this:

How do I add a clickable icon to it like this?


回答1:


How to add an icon to the AppBar

You can add an icon to the AppBar by adding an IconButton widget to the actions list of the AppBar.

AppBar(
  title: Text('My App'),
  actions: <Widget>[
    IconButton(
      icon: Icon(
        Icons.settings,
        color: Colors.white,
      ),
      onPressed: () {
        // do something
      },
    )
  ],
),

See also

  • AppBar Basics documentation
  • How can I have clickable text in the AppBar in Flutter


来源:https://stackoverflow.com/questions/57941227/how-to-add-icon-to-appbar-in-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!