如何在Flutter中将图标添加到AppBar [英] How to add icon to AppBar in Flutter

查看:1158
本文介绍了如何在Flutter中将图标添加到AppBar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个像这样的AppBar:

If I have an AppBar like this:

如何向其添加可点击的图标?

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

推荐答案

如何向AppBar添加图标

您可以通过将IconButton小部件添加到AppBar的actions列表中来向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
      },
    )
  ],
),

另请参见

  • AppBar基础文档
  • 如何在Flutter中的AppBar
  • See also

    • AppBar Basics documentation
    • How can I have clickable text in the AppBar in Flutter
    • 这篇关于如何在Flutter中将图标添加到AppBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆