flutter_svg
flutter_svg copied to clipboard
Failed to find definition for url(#paint0_linear_883_8164)
I failed to render the svg file completely with flutter svg, because some images are missing, like the image below
Image
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
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?
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.
vector_graphics deals with this better.
I've tried that package, but there's a problem importing the support package vector_graphics_compiler
What's the problem? You may need to pull from github, and it may also require a very recent version of Flutter unfortunately
Error importing package from pub.dev. i already run flutter pub get many times but still failed. I used flutter 3.0.5
@tegarnugroho Bit late, but I had the same problem and fixed it by opening the svg and moving the <defs>...</defs>
to the top.
@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.
Thank you very much, this solved my issue as well.