I'm trying use flutter svg, but load with black svg - svg

I'm trying to use Flutter SVG dependency, i put in the svg in assets, set in pubspec.yaml, and set in my widget, but, the svg load with black container
I've already tried change the svg, and the another svg works fine, but the other not...
final Widget svg = SvgPicture.asset(assetName, semanticsLabel: 'Acme Logo');
the svg in flutter
Here the svg
My expected response was colored svg like the link in codepen, but i got this

This is probably happened because of the corrupted SVG files from the internet. I faced this problem earlier and tried many ways to solve it. But finally, I solved it with the help of this software, svgcleaner.
Download the application into your OS, from here
After installation,
import your SVG.
Click run.
Success! Here you can see your SVGs' cleaned successfully.
After cleaning, you can grab those SVG files from the output folder location and add those files into your flutter app without seeing any black coloured SVG.
It works perfectly fine like this.

I think I am late but this might just help someone. Just make all the styles in your svg image use inline styling otherwise all colors and styling won't be rendered as the tag is not readable by the SvgPicture.

I tried this SVG asset with the latest version of jovial_svg, and it works great! Here's the result:
This version of jovial_svg should be released in a couple of days, but for now it's 1.1.4-rc.4.
(This asset helped me flesh out stylesheet support - thanks!)

I found this site it solved my problem with the svg file that was out of color.
https://iconly.io/tools/svg-cleaner

use this configuration in illustrator before you add it to your project.
https://user-images.githubusercontent.com/2842459/62599914-91de9c00-b8fe-11e9-8fb7-4af57d5100f7.png

If You don't have solution try to convert your image from svg to png and use:
Image.asset('assets/images/image.png',)

Some SVG images uses style tag and if you try to load such image using flutter_svg, image won't render as expected. Currently flutter_svg supports styling through inline styles only and not the style tag that some of SVG files may contain (in my case, I exported image from Adobe XD and it has all styles in tag). When you try to load such SVG images, you will get below error:
======== Exception caught by SVG =================================================================== The following UnimplementedError was thrown in parseSvgElement: The
element is not implemented in this library.
Style elements are not supported by this library and the requested SVG
may not render as intended.
If possible, ensure the SVG uses inline styles and/or attributes
(which are supported), or use a preprocessing utility such as
svgcleaner to inline the styles for you.
This error mentions to use inline style instead of style tag, you can use svgcleaner (as mentioned in #Alif's answer) or similar utility to convert SVG file with inline styling.
For more detials, refer this link to check SVG compatibility with flutter_svg and handling other use-cases

try this:
Container(
child: SvgPicture.asset(
'assets/images/image.svg',
fit: BoxFit.contain,
),
)

Related

How to use transparent SVGs in jasper report and export to pdf

I'm trying to export jasper report to pdf using partially opaque SVGs, but in the pdf the opaque are solid white-ish.
The image expression is:
<imageExpression><![CDATA[net.sf.jasperreports.renderers.SimpleRenderToImageAwareDataRenderer.getInstance(byte[] data)]]></imageExpression>
In the background it seems jasper is using Apache BatikRenderer and XML Graphics.
Here are even examples of transparency support:
https://xmlgraphics.apache.org/fop/trunk/graphics.html#svg
According to this link, transparency should be supported: https://xmlgraphics.apache.org/fop/dev/svg.html
There is even a pdf-example which works with transparency.
After looking at how the SVG in the example defined transparency, I noticed my SVGs differed:
In the example "fill-opacity" is used, while my SVGs used simply "opacity".
By changing opacity to fill-opacity in the SVG, the transparency also worked in the pdf generated by jasper. (Related thread
svg opacity vs fill-opacity)
Now I faced 2 options:
One solution would be to write a script that modifies the svg xml and replaces opacity with fill-opacity.
Another option was to see if the source of the SVGs could be changed so that I would get SVGs using fill-opacity in the first place.
The source outputting SVGs in my case was matplotlib, and the next question was how to get matplotlib to output SVG with fill-opacity instead of opacity:

How do I use SVG images as node styles with yFiles for JavaFX?

I need to style nodes with SVG images but cannot make it work. I am using ImageNodeStyle and passing an SVG image to the constructor. However, applying this style to nodes has no effect. I tried using bitmap images and they work fine.
How do I enable SVG image support for node styling?
yFiles for JavaFX uses JavaFX as the rendering engine and JavaFX unfortunately does not directly support SVG images. You need to convert the SVG image into an image that JavaFX understands and then you will be able to use it with ImageNodeStyle.
Using WebViews would be another option, however this is a very heavyweight solution that does not scale very well for many SVGs. You can surely use for rendering a background SVG, but I would not use hundreds of instances to show simple SVG graphics for the visualization of nodes.
Take a look at this answer to a related SVG/JavaFX question: it proposes a solution to the generic problem, which should also work for this specific issue.

Why doesn't librsvg doesn't export the black paths in a PNG?

Here is an SVG image I want to convert to PNG with librsvg in my program.
This is a PNG version of the SVG exported from Inkscape:
This is a bitmap of the same SVG exported with librsvg:
Only the white portions of the image are exported. The black portions, despite being well-defined in the background, appear transparent.
This problem occurs whether I use the librsvg API or the program rsvg-convert. You can use the W3 validator to see that the SVG's markup is valid.
I notice the same thing happens in the thumbnails of the SVGs in my file browser. Perhaps they're using librsvg?
Upon digging into the files I discovered that, for some reason, the fill of the black portion was set to "fill:currentColor". I don't know where that came from, but changing it to "fill:#000000" fixed the problem.

How to create an Angular Material svg iconset

Does anybody know if SVG iconsets are working as of the current version? (1.0.7)
I'm strugling to use some custom svg with the md-icon directive but I haven't managed to see anything on the screen. Is there something broken or it's simply not implemented?
Any example of how to create and use an svg iconset file?
I know I can use the md-svg-src attribute to load one specific svg file providing its url, but that forces me to have all svgs on separated files and it also doesn't play well with the template cache.
Note: I'm using SVGs for the icons, not an icon font.

SVG file looks different in webbrowser than in Illustrator

I've been doing some stuff in Illustrator and I have a problem with saving a project in to SVG file that I open in webbrowser, It just looks different.
And it hapens only in SVG, if I save it to PDF or PNG it looks how it should.
What am I doing wrong?
That's how it looks in Ai
That's how it looks in webbrowser
Here's a link to download rar file with .ai and .svg that I have.
Since all browsers render it the same way, it would seem likely that this is a bug in the AI SVG export filter.
To me it looks like you are applying a blend mode ("Overlay" perhaps?) to the white parts on top of the image. That effect ought to be reproducible using SVG filters, but perhaps AI's exporter doesn't support that yet.
If you are using an "odd" blend mode, try changing it, or reproducing the effect another way.
Individual pixel control needed in identical svg conversion is not possible. SVG creates only specific shapes. The Ai app conversion seems to use opacity to provide the color shades. You could probably tweek opacity and add some svg filters to improve the svg.
Print your design in a . pdf file instead of exporting it directly. Then open the printed .pdf back in Illustrator and export the .svg from this one, it shoud do the trick.

Resources