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 :)
Author by
Ravi
Updated on December 08, 2022Comments
-
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 over 3 yearsThat 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 over 3 yearsThis is in fact the official Flutter answer to this question: github.com/flutter/flutter/issues/10906#issuecomment-385723664 (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 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 over 3 yearsSorry, didn't notice. There is a library that could help you to achieve desired effect: pub.dev/packages/easy_rich_text