For text, we generally use Text widget, for example:
Text("HelloWorld",
style: TextStyle(
fontSize: 14.0,
color: Colors.black,
));
When you need to bold and change the color of HelloWorld, you can rewrite it as a rich text widget RichText
and use TextSpan
it for splicing. The writing method is as follows:
RichText(
text: TextSpan(
// 注意:TextSpan需要指定样式
// TextSpan子组件会继承父组件的样式
style: TextStyle(
fontSize: 14.0, //设置大小
color: Colors.red,//设置颜色
),
children: <TextSpan>[
TextSpan(text: "Hello"),
TextSpan(text: "World", style: new TextStyle(fontWeight: FontWeight.bold)),//其他样式设置粗体
],
),
);