Flutter Replace Override App Bar Back Button Android iOS Example

App Bar back button is base of every mobile application which has multiple activities screens. Using the App Bar back button mobile UI provides simple navigation to their app users to go back to previous screen. By default the back arrow button is fixed in every flutter android iOS application but we can easily change it by using custom Icons or widgets. In today’s tutorial we are replacing the current app bar icon with new icon from Icon library. So in this tutorial we would Flutter Replace Override App Bar Back Button Android iOS Example Tutorial.

Contents in this project Flutter Replace Override App Bar Back Button Android iOS Example Tutorial:

1. Import material.dart package in your app’s main.dart file.

2. Create void main runApp() method and here we would call our main First application screen named as FirstScreen().

3. Create first app screen class named as FirstScreen extends StatelessWidget. In this class we would simply create a Raised Button from which we would navigate to next screen.

  • gotoNextActivity : In this function we would make the Navigator.push() method to navigate to next activity screen by passing next class name which is SecondScreen().

4. Creating next class named as SecondScreen extends StatelessWidget.

5. Creating a function named as goBack with context argument. In this function we would make Navigator.pop(context) method to go back to previous activity screen.

6. Creating Widget Build area in your SecondScreen class. Now we would make the AppBar widget replaced icon image.

  • automaticallyImplyLeading : Controls whether we would try to implicit leading widget to null.
  • title : Used to set the Title in App bar.
  • leading : Used to override the current back arrow button.

Note : I am using the Icons library to show Home icon in App bar. You can also use here any widget.

7. Creating 1 Raised Button widget in body area to navigate to previous screen.

8. Complete source code for main.dart file:

Screenshots:

Flutter Replace Override App Bar Back Button Android iOS Example

Leave a Reply

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