SvgPicture:SVG 图形周围可能有边框吗?

问题描述 投票:0回答:1

我希望能够为 SVG 图像周围的边框设置不同的颜色。

目前我只能像这样设置图像的颜色:

SvgPicture.asset(
  'assets/images/example.svg',
  colorFilter: ColorFilter.mode(Colors.black, BlendMode.srcIn),
),

有没有办法在图像周围绘制边框?

flutter flutter-image
1个回答
0
投票

是的,可以在 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 图像调整高度、宽度和边框属性。

© www.soinside.com 2019 - 2024. All rights reserved.