Flutter App Bar: A Step-by-Step Guide

Flutter can show a drawer or back control even when you omit leading from the AppBar. I was surprised that automaticallyImplyLeading can turn off that inference.

Choose whether the screen needs a leading control or actions tied to it. Find the AppBar in Scaffold’s appBar slot at the top of the screen.

What is a Flutter AppBar?

A Flutter AppBar is a Material Design toolbar widget placed at the top of a screen through the appBar property of a Scaffold.

The toolbar has a leading slot before its title and an actions list after it. Its bottom slot can hold a TabBar.

SlotTypical use
leadingBack, menu, or another navigation control
titleScreen name or compact title widget
actionsButtons for tasks related to this screen
bottomTabs below the toolbar

Prerequisites

Put this complete app entry point in lib/main.dart, then run it on a configured simulator or device.

  • Flutter SDK and a configured target device or simulator.
  • The material library import, which provides MaterialApp, Scaffold and AppBar.

Build a Flutter AppBar

Start with a MaterialApp and give its home Scaffold an AppBar. This version includes a drawer, so the custom leading button needs a context below Scaffold to open it.

Step 1: Add the screen and toolbar

import 'package:flutter/material.dart';

void main() {
  runApp(const AppBarDemo());
}

class AppBarDemo extends StatelessWidget {
  const AppBarDemo({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          leading: Builder(
            builder: (context) => IconButton(
              tooltip: 'Open navigation',
              icon: const Icon(Icons.menu),
              onPressed: () => Scaffold.of(context).openDrawer(),
            ),
          ),
          title: const Text('Profile'),
          centerTitle: true,
          actions: [
            IconButton(
              tooltip: 'Search',
              icon: const Icon(Icons.search),
              onPressed: () {},
            ),
          ],
          backgroundColor: Colors.indigo,
          foregroundColor: Colors.white,
        ),
        drawer: const Drawer(
          child: SafeArea(
            child: ListTile(title: Text('Navigation')),
          ),
        ),
        body: const Center(
          child: Text('Profile details'),
        ),
      ),
    );
  }
}

The leading control, title and actions are siblings within AppBar, while the drawer belongs to Scaffold. Builder creates a descendant context, so Scaffold.of(context) can find the Scaffold that owns the drawer.

Step 2: Choose which controls belong in each slot

Use leading for navigation and actions for commands tied to the current screen. I chose IconButton rather than bare Icon widgets here because each visible control should have an action and a tooltip.

Reserve Icon for decoration, and leave Flutter’s inferred back or drawer control in place unless your replacement preserves navigation.

Customize the AppBar surface

Set backgroundColor for the bar’s fill and foregroundColor for its default text and icon color. The example uses a white foreground on an indigo surface, then centers the title without changing the slot order.

PropertyWhat it changesWhen to set it
backgroundColorAppBar Material surfaceWhen the screen needs a defined bar color
foregroundColorDefault title and icon colorWhen the default foreground lacks contrast
centerTitleTitle alignmentWhen the design calls for a centered title
elevationSurface depthWhen the bar needs separation from the body

A child widget with its own explicit style can override the AppBar’s default foreground. Set that child’s style directly when one title or icon needs a different color.

Verify the bar and fix common mismatches

Run the app on a simulator or device and check that the title, navigation control and action appear in their intended positions. The retained screenshot illustrates the three slots, not the colors set in the code sample.

Flutter AppBar with a leading menu icon, centered title, and trailing notification action
A basic AppBar places navigation before its title and screen actions after it.

If a menu or back arrow appears without a leading widget in your code, Flutter may have inferred it. AppBar uses Scaffold.drawer for a drawer control or a previous Navigator route for a back button. Set automaticallyImplyLeading to false to disable that inference.

If the color looks different from the value you set, check whether the app’s theme supplies AppBar defaults and whether the title or icons set their own styles. To remove the bar from one screen, omit the appBar argument from that screen’s Scaffold.

Keep navigation behavior intentional

An AppBar takes part in screen navigation as well as presentation. Keep Flutter’s inferred drawer or back behavior when it matches the route, and replace it only when the custom leading control performs the right action.

For a screen that has no leading navigation control, disable inference deliberately:

automaticallyImplyLeading: false

Flutter AppBar questions

These answers cover the color and navigation questions that come up when you first place an AppBar in a screen.

What is an AppBar in Flutter?

AppBar is a Material Design toolbar widget, usually placed in Scaffold.appBar to show a screen title, navigation control, and related actions.

How do I change the AppBar color in Flutter?

Set backgroundColor on AppBar to change its surface. Set foregroundColor to choose the default text and icon color, and keep enough contrast for both to remain readable.

How do I remove the AppBar in Flutter?

Remove the appBar argument from the screen’s Scaffold. Do not create an empty AppBar when the screen should not have a top toolbar.

Why does Flutter show a back or menu button automatically?

When leading is omitted, AppBar can infer a drawer button from Scaffold.drawer or a back button from a previous Navigator route. Set automaticallyImplyLeading to false to disable that inference.

Sushant Dhiman
Sushant Dhiman

Sushant Dhiman writes beginner-friendly Flutter and Dart tutorials covering widgets, layouts, navigation, dialogs, and state. He also covers Node.js, Express, and jQuery fundamentals.

Articles: 14