Flutter: How to change the color in the background (or overlay color) of an Icon when it's pressed?

1.8k views Asked by At

Here my code:

IconButton(
          icon: Icon(CupertinoIcons.add_circled),
          color: Colors.orange,
          iconSize: CustomTheme.iconSize,
          splashColor: Colors.pink,
        
          onPressed: () {
           .....anything
          },
        ),

When I press the IconButton on the left side, it gets a grey circled background which will be filled by the pink splash color.

My question: How can I change the GREY color or even remove it completely???

Unpressed Icon ---> When Icon is pressed ----> Pressed Icon

2

There are 2 answers

0
Abdallah Abdel Aziz On

add the following property

highlightColor: Colors.transparent,
0
Đạt Trần On

You need to set 2 properties to Colors.transparent

IconButton(
    splashColor: Colors.transparent,
    highlightColor: Colors.transparent,