本文介绍了如何在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
- AppBar Basics documentation
- How can I have clickable text in the AppBar in Flutter
See also
这篇关于如何在Flutter中将图标添加到AppBar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!