如果我有这样的 AppBar:
如何像这样向它添加可点击的图标?
您可以通过将 IconButton 小部件添加到 AppBar 的actions
列表来将图标添加到 AppBar。
AppBar(
title: Text('My App'),
actions: <Widget>[
IconButton(
icon: Icon(
Icons.settings,
color: Colors.white,
),
onPressed: () {
// do something
},
)
],
),
用于leading
左侧图标和actions
右侧。
AppBar(
centerTitle: true,
title: Text('AppBar'),
leading: IconButton(
onPressed: () {},
icon: Icon(Icons.home),
),
actions: [
IconButton(
onPressed: () {},
icon: Icon(Icons.call),
),
IconButton(
onPressed: () {},
icon: Icon(Icons.more_vert),
),
],
)