Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make it affect device font size to RichText and TextSpan

I have a problem with RichText and TextSpan widgets. All Text widgets are affected by device font size (changed in settings) but RichText not. Any ideas about to solve it?

like image 392
Maikzen Avatar asked Oct 20 '25 04:10

Maikzen


2 Answers

I have solved it this way:

RichText(
    textScaleFactor: MediaQuery.of(context).textScaleFactor, <--- add this
    text: ...
)
like image 153
Maikzen Avatar answered Oct 22 '25 17:10

Maikzen


Actually RichText is one of the lower level widgets that you need to handle many things yourself.

You should try to use Text.rich() instead. It's pretty much the same thing as RichText but inherits styles from the parent widget tree.

like image 37
user1032613 Avatar answered Oct 22 '25 17:10

user1032613



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!