如何格式化要在Flutter中显示的文本 [英] How to format text to be displayed in Flutter

查看:242
本文介绍了如何格式化要在Flutter中显示的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在屏幕上显示以下文本,并正确显示上标。

I want to display following text on screen with superscripts being displayed properly. How to do that in flutter?

推荐答案

您可以使用 RichText Unicode

  final defaultStyle = TextStyle(color: Colors.black);
  final blueStyle = TextStyle(color: Colors.blue);


        return Center(
              child: RichText(
                text: TextSpan(
                    text: "c. 10\u{207B}\u{2076} seconds: ",
                    style: defaultStyle,
                    children: [
                      TextSpan(text: "Hadron epoch ", style: blueStyle, children: [
                        TextSpan(
                          style: defaultStyle,
                          text:
                              "begins: As the universe cools to about 10\u{00B9}\u{2070} kelvin,",
                        ),
                      ])
                    ]),
              ),
            );

更多信息: https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts

这篇关于如何格式化要在Flutter中显示的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆