flutter_svg icon indicating copy to clipboard operation
flutter_svg copied to clipboard

Failed to find definition for url(#paint0_linear_883_8164)

Open tegarnugroho opened this issue 2 years ago • 5 comments

I failed to render the svg file completely with flutter svg, because some images are missing, like the image below Image Screen Shot 2022-07-15 at 16 05 31

error message `═══════ Exception caught by SVG ═══════════════════════════════════════════════ The following assertion was thrown while parsing AssetBundlePictureKey(bundle: PlatformAssetBundle#46450(), name: "assets/images/splash.svg", colorFilter: null, theme: SvgTheme(currentColor: Color(0xff000000), fontSize: 48.0, xHeight: 24.0)) in _getDefinitionPaint: Failed to find definition for url(#paint0_linear_883_8164)

This library only supports and xlink:href references that are defined ahead of their references.

This error can be caused when the desired definition is defined after the element referring to it (e.g. at the end of the file), or defined in another file.

This error is treated as non-fatal, but your SVG file will likely not render as intended ════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by SVG ═══════════════════════════════════════════════ Failed to find definition for url(#pattern0) ════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by SVG ═══════════════════════════════════════════════ Failed to find definition for url(#pattern1) ════════════════════════════════════════════════════════════════════════════════`

svg file https://drive.google.com/file/d/1RImrm5gwX9kHWycs2eKOvx6Ehddos1Z9/view?usp=sharing

can you give me some solutions?

tegarnugroho avatar Jul 15 '22 09:07 tegarnugroho

This is partly because of #102

Since flutter_svg doesn't know if the def will be defined later, it just errors in this condition so the developer can fix it. In this particular case, the def doesn't exist at all - chrome happily ignores this, but flutter_svg does not.

dnfield avatar Jul 15 '22 15:07 dnfield

vector_graphics deals with this better.

dnfield avatar Jul 15 '22 15:07 dnfield

I've tried that package, but there's a problem importing the support package vector_graphics_compiler

tegarnugroho avatar Jul 18 '22 03:07 tegarnugroho

What's the problem? You may need to pull from github, and it may also require a very recent version of Flutter unfortunately

dnfield avatar Jul 18 '22 16:07 dnfield

Error importing package from pub.dev. i already run flutter pub get many times but still failed. I used flutter 3.0.5

tegarnugroho avatar Jul 20 '22 04:07 tegarnugroho

@tegarnugroho Bit late, but I had the same problem and fixed it by opening the svg and moving the <defs>...</defs> to the top.

wouter-ham avatar Nov 17 '22 09:11 wouter-ham

@tegarnugroho Bit late, but I had the same problem and fixed it by opening the svg and moving the <defs>...</defs> to the top.

Thank you so much, this solved my problem as well.

ffranco-a avatar Nov 17 '22 16:11 ffranco-a

Thank you very much, this solved my issue as well.

WeappDevs avatar Aug 01 '23 11:08 WeappDevs