我希望能够为 SVG 图像周围的边框设置不同的颜色。
目前我只能像这样设置图像的颜色:
SvgPicture.asset(
'assets/images/example.svg',
colorFilter: ColorFilter.mode(Colors.black, BlendMode.srcIn),
),
有没有办法在图像周围绘制边框?
是的,可以在 Flutter 中的 SVG 图形周围添加边框。我认为这就是你可以做到这一点的方法。将 SVG 图形包装在 Container 小部件中,并设置容器的 decoration 属性以包含边框。
具体操作方法如下:
Container(
width: 200,
height: 200,
decoration: BoxDecoration(
border: Border.all(
color: Colors.black,
width: 2.0,
),
),
child: SvgPicture.asset(
'assets/images/example.svg',
),
),
根据您的 svg 图像调整高度、宽度和边框属性。