flutter_svg_web_example icon indicating copy to clipboard operation
flutter_svg_web_example copied to clipboard

Flutter web color not working

Open jefrisingh opened this issue 6 years ago • 0 comments

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<String> 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, ); } }); }

jefrisingh avatar Apr 27 '20 03:04 jefrisingh