如何在 Flutter 中显示指数字符串?

How to display exponent string in Flutter?

我很难在 Flutter Web 屏幕上显示这种类型的字符(迷你 2):

我一直在四处寻找,但没有任何好的结果。目前是否有任何现有的包或方法可以干净地显示它?

您可以在 WidgetSpan 中使用偏移 属性。

RichText(
  text: TextSpan(children: [
    TextSpan(text: '90 m',),
       WidgetSpan(
          child: Transform.translate(
            offset: const Offset(2, -4),
             child: Text(
                    '2',
                   //superscript is usually smaller in size
                   textScaleFactor: 0.7,
              ),
          ),
        )
  ]),
)

或者使用指数2的Unicode

Text("90 m\u00B2"),