10

I want to put a tintColor on my IconButton(upper right corner) so I don't have to put same image of different colors in my project.

How do you do tintColor in Flutter?

      @override
      Widget build(BuildContext context) {
        return Scaffold(
          resizeToAvoidBottomPadding: true,
          backgroundColor: SILVER,
          appBar: AppBar(
            title: Text(
            APP_NAME,
            style: TextStyle(
              color: RED,
              fontFamily: 'Allan')),

          // Action buttons
          actions: < Widget > [
            Container(
              width: 45,
              child: 
                IconButton(
                  color: BLACK,
                  icon: Image.asset("assets/images/ic_planet.png"),
                  tooltip: "Planets",
                  onPressed: () {
                    _handleSelectedAction();
                  },   
            )
          ...
      )
    ],

Here's what the icon looks like on the upper right corner

Anton
  • 255
  • 1
  • 2
  • 10

1 Answers1

22

If you mean the actual icon color, you can set that on the Image.asset constructor:

Image.asset(..., color: Colors.orange)

Icons have it too:

Icon(..., color: Colors.orange)

For some reason it's not working for me to set the color directly on the IconButton.

Edman
  • 5,335
  • 29
  • 32