dnfield / flutter_svg

SVG parsing, rendering, and widget library for Flutter
MIT License
1.66k stars 454 forks source link

Strange result when rendering complex svg #630

Open Ionaru opened 2 years ago

Ionaru commented 2 years ago

Hi, I am not sure if this is the correct place to discuss my issue, because I am not sure it is flutter_svg related.

Description

I'm trying to display an SVG in my application, but the result is not correct. The SVG contains a series of <defs> and <use> elements where I think the problem lies.

The original SVG: https://evemaps.dotlan.net/svg/Solitude.svg I am aware this SVG contains <style> , <script>, which are not supported by flutter_svg. So I used svgo to clean up the file and got rid of elements I do not need, this is the result: https://gist.github.com/Ionaru/52f1c321c4587c05e512fabe8d0bb26d.

The cleaned up SVG seems to render correctly in browsers and GitHub, but when I pass that file to flutter_svg, it renders like this:

image

My flutter code for this widget is extremely simple, with the file hosted on a local webserver.

Center(
    child: SvgPicture.network(
        'http://127.0.0.1:8080/Solitude.min.svg',
    ),
),

What's going wrong here? Is the modified SVG not valid or is there something in it that flutter_svg cannot parse?

Additional info

Flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.0, on Microsoft Windows [Version 10.0.19044.1387], locale en-NL)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.10.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.3)
[✓] VS Code (version 1.63.0)
[✓] Connected device (3 available)

• No issues found!

flutter_svg version: 1.0.0

dnfield commented 2 years ago

This one is relatively complicated and I'm sure there are bugs here. There are likely issues in the way the use and symbol are getting processed.

Ionaru commented 2 years ago

I'm going to open some separate issues with reproducible behaviour, I'll attempt to make the SVG code as small as possible.

zaif-bsol commented 2 years ago

is my issue #641 related to this? Sorry I don't know much about how SVGs work.

Ionaru commented 2 years ago

I don't think so, see my comment on your issue.

dnfield commented 2 years ago

Looks like there's still one more issue with the way fonts are rendered. I don't know when I'll be able to get back to that, but if you can create a smaller repro again it helps.

Ionaru commented 2 years ago

I'll see if I can isolate the issue.