我想用 Nexa 字体更改我的字体 (amion),用 Roboto 更改其他字母,如何使用 Flutter 更改它? 字体图像
您可以使用RichText小部件,它允许应用于textStyle文本范围。下面是一个示例:
body: Center(
child: RichText(
text: TextSpan(
text: 'Say Hello to ', style: TextStyle(fontFamily: 'Roboto', color: Colors.black, fontWeight: FontWeight.normal),
children: <TextSpan>[
TextSpan(text: 'Amion', style: TextStyle(fontFamily: 'Nexa', color: Colors.black, fontStyle: FontStyle.italic)),
TextSpan(text: ' app !', style: TextStyle(fontFamily: 'Roboto', color: Colors.black, fontWeight: FontWeight.normal))
]
),
),
)
Run Code Online (Sandbox Code Playgroud)
您只需要将 替换fontFamily为您需要的任何内容即可。我只是举了Roboto一个Nexa例子,供大家参考。