dart - 我如何在 TextSpan 中使用 'vertical-align: super'

标签 dart flutter

我想在 TextSpan 上设置“vertical-align: super”。 我想要这样的结果: enter image description here

最佳答案

另一个答案使用了 Unicode 上标字符,但并非所有字符都有上标版本。在这种情况下,您可以将 WidgetSpan 与 Transform.translate 一起使用。您必须调整 fontSize 和 y-offset 直到它适合您的布局。

RichText(
  text: TextSpan(
    children: [
      TextSpan(text: 'Usage (m'),
      WidgetSpan(
        child: Transform.translate(
          offset: const Offset(0.0, -7.0),
          child: Text(
            '3',
            style: TextStyle(fontSize: 10),
          ),
        ),
      ),
      TextSpan(text: ')'),
    ],
  ),
)

关于dart - 我如何在 TextSpan 中使用 'vertical-align: super',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55345513/

相关文章:

dart - For Each 循环在 dart 中创建数组

dart - 从Dart map 中提取 map

flutter :参数格式不正确

android - 为什么 Flutter Build Apk 和 Flutter 安装在 Release 上不起作用

flutter - 如何让 child 在 flutter 中连续适应高度?

flutter -- 创建移动应用程序时对象创建顺序是什么?

flutter - 如何解决 “Expected a value of type ' int',但在Flutter中得到了 'String'类型之一

flutter - 如何在 RaisedButton 的右侧添加图标?

flutter - 迁移到 Dart null safety : best practice for migrating ternary operator null checks? monadic 方法是否太不合常规?

Flutter - 当我推送的页面被后退按钮弹出时如何得到通知?