Flutter:在屏幕上看不到SVG图片

Flutter : Can't see SVG picture on the screen

我尝试使用 svg 格式,但在 phone 屏幕上看不到图片。

颤振代码:

Padding(
                  padding: const EdgeInsets.only(top: 20),
                  child: Container(
                      width: width, 
                      child: SvgPicture.asset(
                        'assets/images/home_logo.svg',
                      )
                ),

SVG 图片:

<svg width="118" height="16" viewBox="0 0 118 16" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<rect width="118" height="16" fill="url(#pattern0)"/>
<defs>
<pattern id="pattern0" patternContentUnits="objectBoundingBox" width="1" height="1">
<use xlink:href="#image0" transform="translate(0 -0.0117015) scale(0.00220264 0.0162445)"/>
</pattern>
<image id="image0" width="454" height="63" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcYAAAA/CAYAAAB6iGhMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAElVJREFUeNrsXU1yIskOlh3shxtM+QQNJ3Cx7wjjTW8NJ8CcADiB8QmMt2yMI9i7fALTJ3D1CYY5wTyylPWgaUMp/zOrUhH0dEzbVJZS0icpJeUFRPqa1stk9+dk90n4/8l3nxl8/5FH5ni9Z6Pdp3OwZ8+7PcssPDvlz27z/7Ph8rL1lFf93Z93B+t9333m3q7X3J7dHeg427NHr3TcpUzXf/8HfP9LYnxdsL9cWBI+9vnGlbBzoIylMG75f3/uPplzwUSGPZ3412HJvEhfKnFysM9Q7Ge5zyaN7nrJnvd2JFslMYCaGnw2k5XBF//C3re3e/bGs30Ka71meHC/+/PBax6g7XxxItP13vs2txWdL/6V7XvvwuCGMiTun9jUKtoU6A2wsO7BonH/rPipqxg5/hZ53BD3mvFstfu8avV4UdA/K57fM+Jl4/u/VLxz15tI7DQgwIED021ApPh25ie2XMe3Dtd4zjkvidnHYTRC2hzD//O1ZUDgJjxCVKEO/0x23/kIdlM8I8LPTIrIsdke1z38njqkUMJ/7373HTn3enVE3wPCOkYH0atOmhD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rf4WXatgzLASqi8geKbE4V8yvs9Q7lVhO3pK+DQA9f7yjznNAJKUDpR5QC/O17jBqob593bM//7bBWAEV9wXkSOZqbPuFUCMcNZt9u5cwEhXxTRF6bSfDXyG+9SM/W7n6/uDiRzqgae8+An8T0iielqRiiY215ETh0Rjjn6gHqkVOdO0ovNlR0mMyp3EkaZsbdPH2eM46Y4q3a/TrbGU0chzLh3G5oFU+XrFM5fpj2LValfef+YNw9d4BYRFK3LTs7vxxtCmOPImiEzCCY9+Loae8P/zQfqnZAjr65oCnD/p3C6roY5htP/CTAAzwYrC8fpipYAAAAASUVORK5CYII="/>
</defs>
</svg>

错误:

I/flutter (15273): unhandled element pattern; Picture key: AssetBundlePictureKey(bundle: PlatformAssetBundle#5121b(), name: "assets/images/home_logo.svg", colorFilter: null)

这张图片在我的浏览器上看起来像这样。但是我在应用程序中看不到它。请看!

据我所知,您不能直接在 Flutter 中渲染 SVG 图像。也尝试使用此包 flutter_svg . Its worth a shot. If not you can refer to this

干杯!