SvgPicture.asset('assets/images/close_icon.svg', color: Colors.white,)
not showing image. output error is
The following StateError was thrown resolving a single-frame picture stream:
Bad state: Could not parse "currentColor" as a color.
The Main Version of Flutter Does Not Support SVG There is an SVG directory in the code of Skia, which is a basic component of Flutter. However, Skia can only serialize images into SVG files. Therefore, you cannot decode or render SVG images with Skia.
Although Flutter doesn't support SVG natively, the Dart-native flutter_svg package has excellent performant and fast support for SVG files.
Scalable Vector Graphics (SVG) is one of the most widely used file image formats in applications. Because it offers several advantages over bitmap files, especially when it comes to retaining image quality while scaling, it’s difficult to start building a Flutter application without first considering using SVG.
To use make the most use of flutter_svg with Adobe Illustrator, you need to follow specific recommendations: Images: choose to embed, not link, to another file to get a single SVG with no dependency on other files Objects IDs: choose layer names in order to add a name to every layer for SVG tags, or use minimal layer names — the choice is yours!
Finally, you can load an SVG from an SVG code: Once you have your SVG file loaded, the first step is to change the color or tint of the image: Using a semantics label helps to describe the purpose of the image and enhances accessibility.
Alternatively, you can add flutter_svg to your pubspec.yaml file: Make sure that you run flutter pub get either in your terminal or using your editor. Once installation is complete, import the package in your Dart code where you want to use this package:
You can open your svg asset assets/images/close_icon.svg
and edit color property from currentColor to any other valid color (like black or white).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With