【发布时间】:2019-04-20 20:33:11
【问题描述】:
来自this question 我正在使用 Flutter 的 SVG 包 (flutter_svg) 来渲染 SVG image。
我想将 SVG 用作Container 背景,Text 在中间。
这是我目前的代码:
Container(
decoration: BoxDecoration(
image: DecorationImage(image: SvgPicture.asset(
'assets/example.svg',
),),
),
children: <Widget>[
Text('Welcome to my Flutter App',
style: Theme.of(context).textTheme.display1.copyWith(
color: Colors.white,
fontWeight: FontWeight.bold
)
),
],
)
我发现的问题是SvgPicture 不是ImageProvider,所以我无法添加BoxDecoration 来获取背景图像。
有没有办法将SvgPicture用作Container的盒子装饰或背景?
【问题讨论】: