If I have an AppBar like this:
How do I add a clickable icon to it like this?
If I have an AppBar like this:
How do I add a clickable icon to it like this?
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
},
)
],
),
leading
parameter of AppBar
to add a widget (including an icon) to the left side. –
Lipid Use leading
for left sided icon and actions
for right sided.
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),
),
],
)
© 2022 - 2024 — McMap. All rights reserved.
InkWell
and have the same effect. I thought there was a lack of trying to find resources and experimenting when there were similar resources regarding making actions clickable in Appbar. – Junjiactions
is list of widgets - doesn't matter what widget you put into - icon or text – Castle