How to change the appBar back button color

Mfreeman picture Mfreeman · Jul 25, 2018 · Viewed 79.5k times · Source

I cannot figure out how to change the appBar's automatic back button to a different color. it's under a scaffold and I've tried to research it but I can't wrap my head around it.

return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.white,
        title: Image.asset(
          'images/.jpg',
          fit: BoxFit.fill,
        ),
        centerTitle: true,
      ),

Answer

diegoveloper picture diegoveloper · Jul 25, 2018

You have to use the iconTheme property from the AppBar , like this:

appBar: AppBar(
  iconTheme: IconThemeData(
    color: Colors.black, //change your color here
  ),
  title: Text("Sample"),
  centerTitle: true,
),

Or if you want to handle the back button by yourself.

appBar: AppBar(
  leading: IconButton(
    icon: Icon(Icons.arrow_back, color: Colors.black),
    onPressed: () => Navigator.of(context).pop(),
  ), 
  title: Text("Sample"),
  centerTitle: true,
),

Even better, only if you want to change the color of the back button.

appBar: AppBar(
  leading: BackButton(
     color: Colors.black
   ), 
  title: Text("Sample"),
  centerTitle: true,
),