Home > database >  Why am I facing with unsupported Svg error
Why am I facing with unsupported Svg error

Time:04-12

I have a SVG file which you can see in here.

I add that svg in pubspec.yaml file. I defined it as static const black = 'assets/svg/badges/black.svg'; in my AppSvg class. And I tried to use it like this in Column:

  SvgPicture.asset(AppSvg.black, height: 100)

But it returns me error below.

════════ Exception caught by SVG ═══════════════════════════════════════════════
The following UnsupportedError was thrown in _Element.svg:
Unsupported operation: Unsupported nested <svg> element.

The root <svg> element contained an unsupported nested SVG element.

Picture key: AssetBundlePictureKey(bundle: PlatformAssetBundle#1fd5a(), name: "assets/svg/badges/black.svg", colorFilter: null, theme: SvgTheme(currentColor: null, fontSize: 14.0, xHeight: 7.0))

Svg's codes:

<svg height="400" viewBox="0 0 400 400" width="400" xmlns="http://www.w3.org/2000/svg"><svg height="380" viewBox="0 0 400 400" width="380" x="10" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" y="10"><path d="m342.9 67.4-122.3-58.9c-13-6.3-28.2-6.3-41.2 0l-122.3 58.9c-13 6.3-22.5 18.1-25.7 32.2l-30.2 132.4c-3.2 14.1.2 28.9 9.2 40.2l84.6 106.1c9 11.3 22.7 17.9 37.1 17.9h135.8c14.4 0 28.1-6.6 37.1-17.9l84.6-106.1c9-11.3 12.4-26.1 9.2-40.1l-30.2-132.5c-3.2-14-12.7-25.9-25.7-32.2z" fill="#16161e"/><path d="m275.1 373h-150.2c-2.9 0-5.5-1.3-7.3-3.5l-93.6-117.4c-1.8-2.2-2.5-5.1-1.8-7.9l33.4-146.4c.6-2.8 2.5-5.1 5.1-6.4l135.3-65.1c2.6-1.2 5.6-1.2 8.1 0l135.3 65.1c2.6 1.3 4.4 3.6 5.1 6.4l33.4 146.4c.6 2.8 0 5.7-1.8 7.9l-93.6 117.4c-1.9 2.2-4.6 3.5-7.4 3.5z" fill="#ffd26d"/><path d="m373.5 243.8-32.9-144.1c-.5-2.2-2-4.1-4.1-5.1l-133.2-64.2c-2.1-1-4.5-1-6.6 0l-133.2 64.2c-2.1 1-3.6 2.9-4.1 5.1l-32.9 144.1c-.5 2.2 0 4.6 1.5 6.4l92.2 115.6c1.4 1.8 3.6 2.9 5.9 2.9h147.8c2.3 0 4.5-1.1 5.9-2.9l92.2-115.5c1.4-1.9 2-4.2 1.5-6.5zm-234.2-153.7 59.3-28.5c.9-.4 2-.4 2.9 0l59.3 28.5c1.6.8 2.3 2.8 1.5 4.4-.6 1.2-1.8 1.9-3 1.9-.5 0-1-.1-1.4-.3l-57.9-27.9-57.8 27.8c-1.6.8-3.6.1-4.4-1.5s-.1-3.6 1.5-4.4zm154.5 216.2-28.4 35.6c-.6.8-1.6 1.2-2.6 1.2h-125.6c-1 0-2-.5-2.6-1.2l-28.4-35.6c-1.1-1.4-.9-3.5.5-4.6s3.5-.9 4.6.5l27.4 34.4h122.5l27.4-34.4c1.1-1.4 3.2-1.7 4.6-.5 1.5 1.1 1.8 3.1.6 4.6z" fill="#16161e"/></svg></svg>

Also I tried SvgCleaner app, hot reload but still didn't work.

CodePudding user response:

There are 2 <svg tags, so try with removing the 1 svg tag, It worked for me.

<svg height="400" viewBox="0 0 400 400" width="400" xmlns="http://www.w3.org/2000/svg">
    <svg height="380" viewBox="0 0 400 400" width="380" x="10" xmlns="http://www.w3.org/2000/svg"

///////

<svg height="380" viewBox="0 0 400 400" width="380" x="10" xmlns="http://www.w3.org/2000/svg"
        xmlns:xlink="http://www.w3.org/1999/xlink" y="10">
        <path
            d="m342.9 67.4-122.3-58.9c-13-6.3-28.2-6.3-41.2 0l-122.3 58.9c-13 6.3-22.5 18.1-25.7 32.2l-30.2 132.4c-3.2 14.1.2 28.9 9.2 40.2l84.6 106.1c9 11.3 22.7 17.9 37.1 17.9h135.8c14.4 0 28.1-6.6 37.1-17.9l84.6-106.1c9-11.3 12.4-26.1 9.2-40.1l-30.2-132.5c-3.2-14-12.7-25.9-25.7-32.2z"
            fill="#16161e" />
        <path
            d="m275.1 373h-150.2c-2.9 0-5.5-1.3-7.3-3.5l-93.6-117.4c-1.8-2.2-2.5-5.1-1.8-7.9l33.4-146.4c.6-2.8 2.5-5.1 5.1-6.4l135.3-65.1c2.6-1.2 5.6-1.2 8.1 0l135.3 65.1c2.6 1.3 4.4 3.6 5.1 6.4l33.4 146.4c.6 2.8 0 5.7-1.8 7.9l-93.6 117.4c-1.9 2.2-4.6 3.5-7.4 3.5z"
            fill="#ffd26d" />
        <path
            d="m373.5 243.8-32.9-144.1c-.5-2.2-2-4.1-4.1-5.1l-133.2-64.2c-2.1-1-4.5-1-6.6 0l-133.2 64.2c-2.1 1-3.6 2.9-4.1 5.1l-32.9 144.1c-.5 2.2 0 4.6 1.5 6.4l92.2 115.6c1.4 1.8 3.6 2.9 5.9 2.9h147.8c2.3 0 4.5-1.1 5.9-2.9l92.2-115.5c1.4-1.9 2-4.2 1.5-6.5zm-234.2-153.7 59.3-28.5c.9-.4 2-.4 2.9 0l59.3 28.5c1.6.8 2.3 2.8 1.5 4.4-.6 1.2-1.8 1.9-3 1.9-.5 0-1-.1-1.4-.3l-57.9-27.9-57.8 27.8c-1.6.8-3.6.1-4.4-1.5s-.1-3.6 1.5-4.4zm154.5 216.2-28.4 35.6c-.6.8-1.6 1.2-2.6 1.2h-125.6c-1 0-2-.5-2.6-1.2l-28.4-35.6c-1.1-1.4-.9-3.5.5-4.6s3.5-.9 4.6.5l27.4 34.4h122.5l27.4-34.4c1.1-1.4 3.2-1.7 4.6-.5 1.5 1.1 1.8 3.1.6 4.6z"
            fill="#16161e" />
    </svg>

  • Related