如何解决我需要在阴影中实现着色器蒙版
我正在尝试仅将ShaderMask
实施为下面容器中颜色为Color(0xFFFF0000)
和透明度为29%
的背景图像,但是我无法执行,下面的代码已经实现了它掩盖了容器的所有元素,但是我只希望掩盖下面代码中的背景图像,请指导我该怎么做?
ShaderMask
( shaderCallback: (rect){
return LinearGradient(
begin: Alignment.center,end: Alignment.center,colors: [
Colors.transparent,Color(0xFFFF0000),]
).createShader(Rect.fromLTRB(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()
)
)
解决方法
您可以使用Stack小部件。然后在该背景容器之上。在您自己的小部件之上。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。