【发布时间】:2020-12-19 17:06:30
【问题描述】:
我正在尝试仅将ShaderMask 实现为下面容器中的背景图像,颜色为Color(0xFFFF0000) 和透明度29%,但我无法这样做,我实现的以下代码将屏蔽所有容器的元素,但我只想屏蔽下面代码中的背景图像,请指导我该怎么做?
ShaderMask
( shaderCallback: (rect){
return LinearGradient(
begin: Alignment.center,
end: Alignment.center,
colors: [
Colors.transparent,
Color(0xFFFF0000),
]
).createShader(Rect.fromLTRB(0, 0, rect.width, rect.height));
},
blendMode: BlendMode.color,
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: new BoxDecoration(
image: DecorationImage(
image: AssetImage('images/background.jpg',),
fit: BoxFit.cover,
),
)
child:Container()
)
)
【问题讨论】:
标签: flutter dart image-masking flutter-image