How can we create a super or sub-script text in flutter like we used to create in android using Spannable String class?

3,345

To answer your question in one liner

final String twoRaisedToFour = '2\u2074';

To know more about such unicodes refer to following answer unicode list

If this helps do accept the answer. Thank you :)

Share:
3,345
Ravi
Author by

Ravi

Updated on December 08, 2022

Comments

  • Ravi
    Ravi over 1 year

    I want to create a superscript text like 2^4 then how can I do this in the flutter. If someone knows please let me know.

  • Greg Price
    Greg Price over 3 years
    That is a lot like SpannableString in Android, but it doesn't have this feature. (Because Flutter currently doesn't have this feature at all; see issue linked in a comment on the question.)
  • Greg Price
    Greg Price over 3 years
    This is in fact the official Flutter answer to this question: github.com/flutter/flutter/issues/10906#issuecomment-3857236‌​64 (There's also github.com/flutter/flutter/issues/224 where doing superscript/subscript in general is one of a long list of features they might add someday, but Unicode is the official answer until then.)
  • Swapnil Kadam
    Swapnil Kadam over 3 years
    @GregPrice I am also waiting for this feature till then, EasyRichText library is the option though it is bit different than RichText as you cannot use it directly as a String which I reckon is a deal breaker.
  • user1991679
    user1991679 over 3 years
    Sorry, didn't notice. There is a library that could help you to achieve desired effect: pub.dev/packages/easy_rich_text