flutter_svg_provider
flutter_svg_provider copied to clipboard
Color should be part of SvgImageKey
The same image is provided by the library when you change only the color
property. This is because color
is incorrectly not part of the ==
(equals) method of SvgImageKey
.
https://github.com/yang-f/flutter_svg_provider/blob/fd32f3c80c7756a8a26520f063ae54f4139c3dc2/lib/flutter_svg_provider.dart#L188
return other is SvgImageKey &&
other.path == path &&
other.pixelWidth == pixelWidth &&
other.pixelHeight == pixelHeight &&
other.scale == scale &&
other.source == source &&
other.svgGetter == svgGetter;
This leads to bugs such as the provider not providing an updated image when your theme updates (such as when enabling dark/light mode) and your image only changes the svg's applied color. For example:
image: DecorationImage(
image: SvgProvider(
"assets/somewhere/in/my/app/some_grpahic.svg",
color: inDarkTheme ? Colors.grey.shade800 : Colors.grey.shade200,
),
),