Flutter Change App Bar Back Button Color in Android iOS Example

By default the app bar Icon has white color but sometimes app developer wants to modify the icon color according to his requirement. In our previous tutorial we have learn about replacing app bar icon you can read it here and this tutorial is the advance part of app bar icon tutorial. We would use the color property to change the app bar icon color. So in this tutorial we would Flutter Change App Bar Back Button Color in Android iOS Example.

Note: I am using the Icon button library in current tutorial, You can also use your own Image widget or any widget at the place of App bar icon.

Contents in this project Flutter Change App Bar Back Button Color in Android iOS Example Tutorial:

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

2. Creating void main runApp() method and here we would call our FirstScreen() class. The FirstScreen is our first home screen for our application.

3. Creating our home screen class named as FirstScreen extends StatelessWidget. This is our first screen for our app in this class we would simply create a button and from which we would navigate to next second screen.

  • gotoNextActivity : In this function we would use Navigator.push() method with SecondScreen next class name to navigate to next screen.

4. Creating another class named as SecondScreen extends StatelessWidget. This is our second screen for app in which we would replace the app bar icon and changed its color.

  •  leading: IconButton(icon:Icon(Icons.home), color: Colors.black,
              onPressed: () {goBack(context);},
            ) – Is used to modify the icon color and also replacing icon.

5. Complete source code for main.dart file:

Screenshots:

Flutter Change App Bar Back Button Color in Android iOS Example

One Comment

  1. K Pradeep Kumar Reddy

    When we specify ‘leading’ field in appBar, do we need to add automaticallyImplyLeading: true ?? It is working without it.

Leave a Reply

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