-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Below is your code with small modification for color, It's working on web but svg's only has one path element, it's not working if svg has more path elements, Can you please find the good solution,
I'm verymuch thankfull for your existing work , :),
P.S : look at hash generation on color, otherwise color chnage won't affect on web
if (kIsWeb) {
String hashCode = assetName.replaceAll('/', '-').replaceAll('.', '-');
return FutureBuilder(
future: rootBundle.loadString(assetName),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData) {
String svgString = snapshot.data;
if(null != color) {
String colorString = color.value.toRadixString(16).substring(2);
hashCode = "$hashCode-$colorString";
svgString = svgString.replaceAll(
'/>', " fill="#$colorString"/>");
print(svgString);
}
print(svgString);
return string(svgString,
width: width, height: height, hashCode: hashCode);
} else if (snapshot.hasError) {
return Container(
width: width,
height: width,
);
} else {
return Container(
width: width,
height: width,
);
}
});
}