How to change what the back button does in dart

How can I change the function of the back button in dart flutter
enter image description here

I really didn’t try anything because tbh, i didn’t find what to try

>Solution :

You need simply to override the leading property in the AppBar with a new IconButton, then set your specific method:

AppBar(
 leading: IconButton(
  onPressed: () {
   print("clicked");
  },
  icon: Icon(Icons.abc),
  ),
 ),

Leave a Reply