flutterdarticonsappbar

Change the icon of BackButon() in my appbar


I have a BackButon() in my appbar , I want to change the default icon of BackButton in FLUTTER.

here is the appBar code:

appBar: AppBar(
        leading: BackButton(
          onPressed: () {
            Get.off(exercisePage());
          },
        ),

        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.only(
              bottomLeft: Radius.circular(30),
              bottomRight: Radius.circular(30)),
        ),
        automaticallyImplyLeading: false,
        title: Padding(
          padding: const EdgeInsets.only(left: 25),
          child: Text(
            'Regular exercise',
            style: TextStyle(
                fontFamily: 'FontMain', fontSize: 22, color: Colors.indigo),
          ),
        ),
        backgroundColor: Color.fromARGB(255, 231, 235, 237),
       
      ),

Solution

  • There is no direct way to change icons in BackButton.

    To change the icon, you need to add a custom IconButton Widget To Leading, and give up on tap for function, or use GestureDetector or InkWell Widget.