gpt4 book ai didi

flutter - 如何在 Flutter 上更改同一行的字体?

转载 作者:行者123 更新时间:2023-12-03 08:51:49 24 4
gpt4 key购买 nike

我想用 Nexa 字体更改我的字体 (amion),用 Roboto 更改其他字母,如何使用 Flutter 更改它? font_Image

最佳答案

您可以使用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))
]
),

),
)

您只需将 fontFamily 替换为您需要的任何内容即可。我只是举了 RobotoNexa 的例子供大家引用。

关于flutter - 如何在 Flutter 上更改同一行的字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58443565/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com