0

I dont have code to show because i couldn't find any solution for this.

Does anyone knows how to show in flutter a power of number like this:

14ug/m3

The 3 in the example meeds to me small and above the m, like in hand writing

I know it can be done with a row of containers and text elements, but asking if there is a way to do it better? If flutter have a build-in mechanism for this?

Erez
  • 1,933
  • 5
  • 29
  • 56
  • 1
    Does this answer your question? [How to format text to be displayed in Flutter](https://stackoverflow.com/questions/53853176/how-to-format-text-to-be-displayed-in-flutter) – Midhun MP Apr 13 '20 at 11:02
  • it is actually the answer over there, should i delete it? – Erez Apr 13 '20 at 14:36

1 Answers1

2

It's called super-script and you can use unicode for it. For example, the 3 in m³ can be written as '\u2083'

Example, the following code produces this :

enter image description here

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,",
                        ),
                      ])
                    ]),
                  ),
              );

The code snippet is taken from here.

Sukhi
  • 13,261
  • 7
  • 36
  • 53