flutter

Remove Back Button from Flutter Appbar

In Flutter, the AppBar widget provides a default back button that allows the user to navigate back to the previous screen. However, there may be cases where you don't want to show this back button.

Here are a few ways you can remove the back button from the AppBar:

  1. Use the automaticallyImplyLeading property:

The AppBar widget has a property called automaticallyImplyLeading which controls whether to show the back button or not. By default, it's set to true which means the back button is shown automatically. You can set this property to false to hide the back button.

Here's an example:

AppBar(
  automaticallyImplyLeading: false, // Remove the back button
  title: Text('My App'),
),
  1. Use a custom leading widget:

Another way to remove the back button is to provide a custom leading widget for the AppBar. You can use any widget as the leading widget, such as an icon, an image, or even a button.

Here's an example:

AppBar(
  leading: Container(), // Provide an empty container as the leading widget
  title: Text('My App'),
),
  1. Use the backwardsCompatibility property:

The AppBar widget has a property called backwardsCompatibility which controls whether to show the back button or not, similar to automaticallyImplyLeading. However, this property is only available in Flutter 2.10 or later.

Here's an example:

AppBar(
  backwardsCompatibility: false, // Remove the back button
  title: Text('My App'),
),
Was this helpful?