如何停止电话中的默认字体大小,从影响Flutter应用程序内部的字体大小?

发布于 2025-01-28 14:06:49 字数 287 浏览 2 评论 0原文

所以我制作了一个扑朔迷离的应用程序。我将所有字体大小定义为动态(按照屏幕尺寸正确渲染)。

一切都很好,直到我在使用较大字体尺寸的手机上打开应用程序(从设备设置中更改)。即使我对文本大小进行编程以动态渲染,但如果用户不使用手机的默认字体大小并将其保持更大的尺寸,则会失败。

现在,问题是,如何停止手机的字体大小(在设置中的文本大小内选择)来影响我的应用程序中的任何内容?无论设置如何,我都想渲染我在Flutter应用程序中定义的文本大小。

有办法做到吗?或者,如果无法阻止这一影响力的部分,我在这里还有哪些其他解决方案?

So I made a Flutter app. I defined all the font sizes to be dynamic (render properly as per the screen sizes).

Everything was working great until I opened the application on a phone which was using a larger font size (changed from within the device settings). Even though, I'd programmed my text size to render itself dynamically, it fails if the user is not using the phone's default font size and has kept it at a larger size.

Now, the question is, How do I stop the phone's font size (chosen within Text Size in Settings) to influence anything that is inside my app? I want to render the same text size that I've defined inside my flutter app, no matter what the settings are.

Is there a way to do it ? Or if there's no way to stop this influencing part, what other solutions do I have here ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愛放△進行李 2025-02-04 14:06:49

您可以覆盖系统提供的文本量表因子:

 MaterialApp(
      builder:  (BuildContext context, Widget child) {
        return MediaQuery(
          data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0, ), //set desired text scale factor here
          child: child,
        );
      },
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );

如果您找到此答案作为帮助,请标记此答案

You can override the the text scale factor provided by the system like this:

 MaterialApp(
      builder:  (BuildContext context, Widget child) {
        return MediaQuery(
          data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0, ), //set desired text scale factor here
          child: child,
        );
      },
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );

if you find this answer as help please mark this answer as accepted

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文