I tried to add color to half of image (50% size of image) but I couldn't give value in flutter

111 Views Asked by At

I tried to add color using ColorFiltered widget to half of image (50% size of image) but I couldn't give value in flutter when I give value then show me error.How I give size or value?

code

ColorFiltered(
                colorFilter: const ColorFilter.matrix([
                  0.0, 0.0, 0.0, 0.0, 0.0, //
                  2.0, 0.0, 0.0, 0.0, 0.0, //
                  0.0, 0.0, 3.0, 0.0, 0.0, //
                  0.0, 0.0, 0.0, 1.0, 0.0, //
                ]),
                child: Image.asset(
                  "assets/bar.png",
                ),
              ),

enter image description here

1

There are 1 best solutions below

0
Ariel H. On

What if you used a Stack and position a Container with the background Color you want, behind your image. Then You could just move the Container to the right or left, giving the illusion of loading. (Assuming your image is transparent.)

I think this should be easier and much more convenient than using a matrix.