Can we Change the background color on an Image in Flutter? Like in this Image I want to change the pink color background color to something else.
In my case, I was trying to color a Transparent PNG
I tried this solution and it's working.
Using ShaderMask class (https://docs.flutter.io/flutter/widgets/ShaderMask-class.html)
Example:
ShaderMask(
child: Image(
image: AssetImage("assets/cat.png"),
),
shaderCallback: (Rect bounds) {
return LinearGradient(
colors: [Colors.blue, Colors.lightBlue],
stops: [
0.0,
0.5,
],
).createShader(bounds);
},
blendMode: BlendMode.srcATop,
)