How to add icon to AppBar in Flutter

Issue

If I have an AppBar like this:

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

Solution

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

Answered By – Suragch

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *