4

flame_svg: ^0.0.1当我尝试加载svg时,我正在使用flutter中的包来渲染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
4

2 回答 2

0

<defs>标签移动到开头结尾的下方<svg>。它将解决 Svg 渲染错误,尤其是当您在flutter_svg包中使用渐变 svg 时。

<svg>
  <defs></defs>
   <path></path>
</svg>
于 2022-03-03T08:08:38.393 回答
0

正如所提供的日志中所建议的那样,您尝试显示的 SVG 似乎不受支持:

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

确保您尝试加载的 SVG 具有受支持的标签。您可以尝试加载不同的 SVG 并查看是否可以显示。

于 2022-01-25T02:00:53.747 回答