flutter - 在 flutter 中格式化文本小部件的部分文本

标签 flutter

我的文本小部件看起来像 Text("Last Active: some location area..") .

我可以使用样式更改完整文本的文本样式。但我只是想将 Last active 更改为粗体。 Text("<b>Last Active</b> some location area name..")

如果我为单独的文本使用 Row,它会起作用,但会出现间距问题。

最好的解决方案是什么。加粗是唯一的要求。

谢谢

最佳答案

RichText 是解决方案

RichText(text: TextSpan(children: [
      TextSpan(text: 'Last Active', style: TextStyle(fontWeight: FontWeight.bold)),
      TextSpan(text: ' some location area name..')
    ]))

关于flutter - 在 flutter 中格式化文本小部件的部分文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52833887/

相关文章:

flutter - 是否可以在 NotificationListener 中检测 ScrollNotification 的来源

android - Phone Auth 自动验证在 Flutter Firebase 中不起作用

dart - flutter/模拟。使用 mockito 测试 API 提供程序,api header 有问题

firebase - flutter/FirebaseAuth : How can I autologin a user at app launch?

json - Flutter 将 json 作为字节发送到 websocket 服务器?

android - 在 Android 版本 11 上面临 flutter 错误

Flutter Bluetooth Serial Discovery - 取消发现(流关闭)

flutter - 如何使用提供程序架构从服务器获取数据

flutter - 点按即可对焦 Flutter 相机

flutter - 根据 Flutter 中的内容调整 Card 高度