美文网首页
Flutter的Builder生成彩虹Text

Flutter的Builder生成彩虹Text

作者: 讠纟纟 | 来源:发表于2020-09-07 09:26 被阅读0次
    Builder(
                  builder: (context) {
                    RenderBox box = context.findRenderObject();
                    final Shader radialGradient =
                        RadialGradient(colors: [Colors.orangeAccent, Colors.cyan],tileMode: TileMode.repeated)
                            .createShader(Rect.fromLTWH(
                                0.0, 0.0, box?.size?.width, box?.size?.height));
                    final Shader linearGradient =
                    LinearGradient(colors: [Colors.orangeAccent, Colors.cyan])
                        .createShader(Rect.fromLTWH(
                        0.0, 0.0, box?.size?.width, box?.size?.height));
                    return Text(
                      "我是一名Flutter初学者,请多多关照!",
                      style: TextStyle(
                          fontSize: 20,
                          fontWeight: FontWeight.bold,
                          foreground: Paint()..shader = radialGradient),//linearGradient
                    );
                  },
                ),
    
    image.png

    相关文章

      网友评论

          本文标题:Flutter的Builder生成彩虹Text

          本文链接:https://www.haomeiwen.com/subject/cyrkektx.html