如何在同一个文本小部件中制作不同的样式?

Kri*_* CN 2 dart flutter

如何对显示文本的不同部分应用不同的样式。如何在颤振中做到这一点?

例子:

你好世界

Kri*_* CN 10

这可以使用 RichText

RichText(
     text: TextSpan(
          text: 'Hello',
          style: TextStyle(fontSize: 22, color: Colors.black),
          children: <TextSpan>[
             TextSpan(
               text: 'World',
               style: TextStyle(
                        fontSize: 24,
                        fontStyle: FontStyle.italic,
                        fontWeight: FontWeight.bold,
               ),
             ),
          ]
     ),
),
Run Code Online (Sandbox Code Playgroud)