Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to invert image color in Flutter?

Tags:

flutter

How I can invert programmatically the color of an image in flutter? I want to invert the full color of the image not only the background.

like image 712
Luca Panteghini Avatar asked May 13 '19 07:05

Luca Panteghini


People also ask

How do you color an image in flutter?

If you want to change the background color dynamically you will first have to make the background transparent by adding an alpha channel mask to the image (again using an image editor) You will then be able to define a background color by putting the image inside a widget that has a background color.


2 Answers

now it's possible using the ColorFiltered widget.

https://api.flutter.dev/flutter/dart-ui/ColorFilter-class.html

You find a detailed explanation on my blog https://www.burkharts.net/apps/blog/over-the-rainbow-colour-filters/

like image 188
Thomas Avatar answered Sep 21 '22 18:09

Thomas


Currently it's not possible to invert colors with out of the box solutions. You can try to use ShaderMask as suggested in this answer. You may also check out BlendMode options.

like image 22
Dominik Roszkowski Avatar answered Sep 24 '22 18:09

Dominik Roszkowski