Search code examples
cssfluttertextmobile

How do I use Text Scale Factor property in flutter


I am having problems with my app.. When i set the fontSize on my phone it works OK but on other peoples phones due to there phone fontSize settings it is affecting the size of the text in my app.. I heard text scale factor can help but i do not know how to use it


Solution

  • You can use MediaQuery.of(context).textScaleFactor but I think using auto_size_text is more efficient.

    EDIT 2 :

    Widget build(BuildContext context){
      return Text(
          'Hello, How are you?',
          textScaleFactor : MediaQuery.of(context).textScaleFactor,
          style: TextStyle(fontWeight: FontWeight.bold,fontSize : 18),
        );
    }
    

    And you can check the usage of this property from here as well as TextStyle class from here.