Flutter Widgets 之 ShaderMask

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)

blendModeProperty is a fusion mode, child is the target image (dst), Shader image source (src), a fusion way of introduction:

Read More:

If this article helpful to you and hope that you come to a "praise" and focus on my public number, thank you very much.

Guess you like

Origin www.cnblogs.com/mengqd/p/12385970.html
Recommended