yang-f / flutter_svg_provider

Use svg as image provider.
https://pub.dev/packages/flutter_svg_provider
Apache License 2.0
47 stars 72 forks source link

suspect wrong color filter mode #31

Open xloc opened 2 years ago

xloc commented 2 years ago

I had a problem when using the color property to re-color the image and found changing the blend mode from srcATop to srcIn fix the problem for me. Is this a bug?

if use color

Container(
  decoration: const BoxDecoration(
    image: DecorationImage(
      image: Svg(
        'assets/grid.svg', 
        size: Size.square(40), 
        color: Colors.black12,
      ),
      repeat: ImageRepeat.repeat,
    ),
  ),
  child: Center(child: Text("Hello", style: TextStyle(fontSize: 80))),
)
image

if change it to srcIn

Container(
  decoration: const BoxDecoration(
    image: DecorationImage(
      image: Svg('assets/grid.svg', size: Size.square(40)),
      repeat: ImageRepeat.repeat,
      colorFilter: ColorFilter.mode(Colors.black12, BlendMode.srcIn),
    ),
  ),
  child: Center(child: Text("Hello", style: TextStyle(fontSize: 80))),
)
image
yang-f commented 2 years ago

What is the specific problem? Can you describe it in detail?

xloc commented 2 years ago

Yes. If you see the example above, I was attempting to use an svg as the background, and I wanted to recolor the strokes to a mild color Colors.black12. I tried to use the color attribute of Svg to recolor the image, but that didn't work. The strokes are still in black. My expectation is the below one where the grid lines are colored in light gray.

yang-f commented 2 years ago

Can u provide the source code of grid.svg

xloc commented 2 years ago

Sure. Here it is

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32"
  fill="none" stroke="#000000" stroke-opacity="0.04">
  <path d="M0 .5H31.5V32" />
</svg>