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 how you do it: Step 1: Locate the MaterialApp widget. Step 2: Inside the MaterialApp, add the theme parameter with ThemeData class assigned. Step 3: Inside the ThemeData add the iconTheme parameter and then assign the IconThemeData . Step 4:Inside the IconThemeData add the color parameter and set its color.
The simplest way to create a button with icon and text in Flutter is to use the new Material button called ElevatedButton with an icon constructor. ElevatedButton. icon() gives you the ability to add the icon and label parameter to the button. The ElevatedButton was introduced with the release of Flutter v1.
Steps to Add Image in Flutter (Local Image) To add image in Flutter app, first of all, create an assets/images folder then add the actual images inside the folder. After this, Add the image path in pubspec. yaml and then display it using the Image. asset() widget.
Just wrap the logic around setState(){} in onPressed() of floatingActionButton. When on click on the FloatingActionButton with Refresh Icon, the icon is changed to Stop.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With