获取两个括号之间的文本,并在字体中应用字体和颜色

问题描述 投票:0回答:1

无论如何都可以在两个括号之间获取文本并应用自定义字体和颜色。

示例:我是(Flutter)开发的(新手)。

现在如何更改newFlutter的颜色

flutter dart
1个回答
0
投票

您可以使用RichText窗口小部件

RichText(
          text: TextSpan(
            text: 'Now how to change color of  ',
            style: TextStyle(color:Colors.black),
            children: <TextSpan>[
              TextSpan(
                  text: 'new ', style: TextStyle(fontWeight: FontWeight.bold,color: Colors.red)),
              TextSpan(text: 'and! '),  TextSpan(
                  text: 'Flutter!', style: TextStyle(fontWeight: FontWeight.bold,color: Colors.green)),
            ],
          ),
        ),

结果

Example

参考

  1. DartPad Example
  2. RichText class
© www.soinside.com 2019 - 2024. All rights reserved.