skip to Main Content

Is there a way to make the textScaleFactor the same everywhere?

I know the way to wrap a MediaQuery for every widget that wants to control the textSacleFactor.

But, it’s not elegant. If I just put the MediaQuery in the MaterialApp, most situations are okay, except using “Navigator.of(context).push” or “showModalBottomSheet” etc.

Do you have any ideas to solve it?

2

Answers


  1. Use this plugin for that https://pub.dev/packages/sizer

    use .sp to resize

    Login or Signup to reply.
  2. You can use Screen Util for it and just put .sp to get it:- https://pub.dev/packages/flutter_screenutil
    Example:

    Text(
      '16sp,if data is not set in MediaQuery,my font size will change with the system.',
      style: TextStyle(
        color: Colors.black,
        fontSize: 16.sp, //<- Here
      ),
    ),
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search