Home > Software engineering >  How to add back icon image in app bar in flutter
How to add back icon image in app bar in flutter

Time:11-23

In Flutter i need to add back icon image in app bar in flutter. I m new to flutter learning & developing any help would be appreciated.

I need to customise the back button image in app bar

Please let me know How to add back icon image in app bar in flutter?

CodePudding user response:

There is a widget call : BackButtonIcon()

AppBar(
   leading: IconButton(
   onPressed: () {
      Navigator.of(context).pop();
   },
   icon: const BackButtonIcon(),
                          ),)

CodePudding user response:

if you use an AppBar widget in your Scaffold, the back arrow icon will be displayed automatically when you push a new page with the Navigator.

If you want to add manually the icon, you can add it in the leading property inside the AppBar:

AppBar(
  leading: IconButton(
    icon: const BackButtonIcon(),
    onPressed: () { },
  )
);

CodePudding user response:

Back IconButton is automatically enabled when you Navigate from another screen.

By using this code

Navigator.push(
    context,
    MaterialPageRoute(builder: (context) => SecondRoute()),
  );

If you already Navigated from another screen and are still not showing then slightly change the AppBar field

AppBar(
automaticallyImplyLeading:true,
)
  • Related