Let Shader ShaderMask can be used on any of the controls, such as the use of gradients can be used to achieve ShaderMask on Text:
ShaderMask(
shaderCallback: (Rect bounds) {
return RadialGradient(
center: Alignment.topLeft,
radius: 1.0,
colors: <Color>[Colors.yellow, Colors.deepOrange],
tileMode: TileMode.mirror,
).createShader(bounds);
},
blendMode: BlendMode.srcATop,
child: Text('老孟,一枚有态度的程序员',style: TextStyle(fontSize: 30),),
)
effect:
shaderCallback
Shader need to return an object that can be generated directly by the gradient Shader Class:
RadialGradient(...).createShader(rect)
blendMode
Property is a fusion mode, child is the target image (dst), Shader image source (src), a fusion way of introduction:
Read More:
- Flutter series overview
- Flutter Widgets 之 Expanded和Flexible
- Flutter Widgets 之 AnimatedList
- Flutter Widgets 之 SliverAppBar