如何将 svg 图标导入 icondata

bra*_*aul 5 dart flutter

我是 flutter 新手,使用名为 FloatBoxPanel 的插件,对于panelIcon需要 IconData 的属性,我创建了一个 svg 图标,现在我不知道如何使用它。直接使用会报错:

The argument type 'Icon' can't be assigned to the parameter type 'IconData'. (Documentation)
The argument type 'SvgPicture' can't be assigned to the parameter type 'IconData'. (Documentation)
Run Code Online (Sandbox Code Playgroud)

这是此代码的一部分,请告诉我是否可能,谢谢!!

The argument type 'Icon' can't be assigned to the parameter type 'IconData'. (Documentation)
The argument type 'SvgPicture' can't be assigned to the parameter type 'IconData'. (Documentation)
Run Code Online (Sandbox Code Playgroud)

Vra*_*hah 1

该类型IconData必须有一个Icon(). 您不能将其设置为图像或 Svg。

你有2个解决方案。要么使用 @Thierry 所说的将 Svg 转换为 an Icon,要么更改包中的代码以支持 anImage而不是Icon.