recolored method

SvgWrapper recolored(
  1. Map<String, String> colorMap
)

Returns a new svg wrapper with new colors, where the key to the map is the color to replace and the value is the new color

Implementation

SvgWrapper recolored(Map<String, String> colorMap) {
  String newContent = content;

  for (final colorPair in colorMap.entries) {
    newContent = newContent
        .replaceAll('fill="${colorPair.key}"', 'fill="${colorPair.value}"')
        .replaceAll('fill:${colorPair.key};', 'fill:${colorPair.value};');
  }

  return SvgWrapper(name: name, content: newContent);
}