Flutter how to force font size datetime picker flutter?

316

You are almost there.... I had the same issue too. I tried so much time and found out the solution.

The below builder is the parameter of "showDatePicker".

builder: (context, child) {
         return MediaQuery(
                data: MediaQuery.of(context).copyWith(textScaleFactor: 1),
                child: Theme(......)
         )
}

Just wrap the theme with MediaQuery. That's all. It works smoothly for me.

Share:
316
Kyle Houston - Phi Anh
Author by

Kyle Houston - Phi Anh

Hi there, I'm currently working as a full-stack developer for a start-up company. Mostly I work on .NET framework for web application projects. I'm always seeking for a better solution to solve the problems of the company and widen my knowledge. Furthermore, I'm also working on some flutter projects and using BLOC framework. I like to improve the project structure and code quality through learning online courses

Updated on December 21, 2022

Comments

  • Kyle Houston - Phi Anh
    Kyle Houston - Phi Anh over 1 year

    I'm working on a project and meet this problem, with the device which is modified font of iPhone system in Setting => General => Accessibility => Larger Text is ON, I worked around and find a way to fix font size with the code below:

    new MaterialApp(
      builder: (context, child) {
        return MediaQuery(
           data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0),
           child: //element go here
        )
      }
    )
    

    This way is worked fine with common TextView and pop-up but I'm using flutter_datetime_picker

    I read the documentation and still not find out how to fix font of DateTime picker when the pop-up shows up, How can I solve this problem, thank you, here is a picture to demonstrate it. enter image description here

  • Kyle Houston - Phi Anh
    Kyle Houston - Phi Anh about 2 years
    Yah it seems that Flutter has fixed this issue, it will automatically scaled down the calendar size itself without any custom configuarations
  • Aswanath C K
    Aswanath C K about 2 years
    I don't think so, without configure flutter won't actually do it. I had the same situation, I need to force it. If you find the answer right please check it. Thanks