作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想用 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
替换为您需要的任何内容即可。我只是举了 Roboto
和 Nexa
的例子供大家引用。
关于flutter - 如何在 Flutter 上更改同一行的字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58443565/
我是一名优秀的程序员,十分优秀!