How to display exponent string in Flutter?

408

You can make use of offset property in 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,
              ),
          ),
        )
  ]),
)

or use the Unicode of exponent 2

Text("90 m\u00B2"),
Share:
408
Bach
Author by

Bach

Updated on December 29, 2022

Comments

  • Bach
    Bach over 1 year

    I'm struggling to display this type of character (the mini 2) on a Flutter Web screen:
    enter image description here

    I've been looking around but without any good results. Is there currently any existing package or method to display this cleanly?