如何在 Flutter 中显示任何带有幂的数字?
How can I display any number with a power in Flutter?
这是我的情况(简化):
我有两个输入:
- 一个数(a)
- 另一个数字(b)
如何使用 Flutter 在前端很好地显示 a^b(a 的 b 次方)?
您可以在 WidgetSpan 中使用偏移 属性。我使用下面的代码来显示航班交叉。偏移量 dx 和 dy 值可帮助您根据需要设置上标或下标。
RichText(
text: TextSpan(children: [
TextSpan(
text: '9:30 - 2:30',
style: TextStyle(color: Colors.black)),
WidgetSpan(
child: Transform.translate(
offset: const Offset(2, -4),
child: Text(
'+2',
//superscript is usually smaller in size
textScaleFactor: 0.7,
style: TextStyle(color: Colors.red),
),
),
)
]),
)
这是我的情况(简化):
我有两个输入:
- 一个数(a)
- 另一个数字(b)
如何使用 Flutter 在前端很好地显示 a^b(a 的 b 次方)?
您可以在 WidgetSpan 中使用偏移 属性。我使用下面的代码来显示航班交叉。偏移量 dx 和 dy 值可帮助您根据需要设置上标或下标。
RichText(
text: TextSpan(children: [
TextSpan(
text: '9:30 - 2:30',
style: TextStyle(color: Colors.black)),
WidgetSpan(
child: Transform.translate(
offset: const Offset(2, -4),
child: Text(
'+2',
//superscript is usually smaller in size
textScaleFactor: 0.7,
style: TextStyle(color: Colors.red),
),
),
)
]),
)