我正在使用flame_svg: ^0.0.1flutter 中的包来渲染 svg,当我尝试加载 svg 时,它会给出以下错误
flutter: The following assertion was thrown in _getDefinitionPaint:
flutter: Failed to find definition for url(#paint0_linear)
flutter: This library only supports <defs> and xlink:href references that are defined ahead of their
flutter: references.
flutter: This error can be caused when the desired definition is defined after the element referring to it
flutter: (e.g. at the end of the file), or defined in another file.
flutter: This error is treated as non-fatal, but your SVG file will likely not render as intended
Run Code Online (Sandbox Code Playgroud)
Wai*_* Ko 13
将<defs>标签移至开口末端下方<svg>。它将解决 Svg 渲染错误,特别是当您在flutter_svg包中使用渐变 svg 时。
<svg>
<defs></defs>
<path></path>
</svg>
Run Code Online (Sandbox Code Playgroud)
说明:
SVG 元素用于嵌入可在 SVG 图像内重复使用的定义。
所以flutter中的这些svg插件会顺序读取svg代码。现在,如果找不到定义,则会抛出错误。这就是为什么定义需要位于顶部
正如所提供的日志中所建议的,您尝试显示的 SVG 似乎不受支持:
flutter: This library only supports <defs> and xlink:href references that are defined ahead of their
flutter: references.
Run Code Online (Sandbox Code Playgroud)
确保您尝试加载的 SVG 具有受支持的标签。您可以尝试加载不同的SVG,看看是否可以显示。
| 归档时间: |
|
| 查看次数: |
5551 次 |
| 最近记录: |