Skip to content

initial textScaleFactor on app first run is wrong #178238

Closed

Description

@asaarnak

Steps to reproduce

  1. Set your Chrome > settings > appearance > font size to Large.
  2. flutter create test_web_font_scaling --platforms=web
  3. Copy example: https://api.flutter.dev/flutter/widgets/WidgetsBindingObserver/didChangeTextScaleFactor.html
  4. Fix late init error in example.
  5. flutter run --release
  6. Copy the URL in your chrome a few times in a new tab until the "Current scale factor" is not updated.

Expected results

Should show "Current scale factor: 1.25"

Actual results

Shows "Current scale factor: 1"

Code sample

Reproducible sample
import 'package:flutter/material.dart';

void main() {
  return runApp(const MaterialApp(home: TextScaleFactorReactor()));
}

class TextScaleFactorReactor extends StatefulWidget {
  const TextScaleFactorReactor({super.key});

  @override
  State<TextScaleFactorReactor> createState() => _TextScaleFactorReactorState();
}

class _TextScaleFactorReactorState extends State<TextScaleFactorReactor>
    with WidgetsBindingObserver {
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
  }

  @override
  void dispose() {
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  double _lastTextScaleFactor =
      WidgetsBinding.instance.platformDispatcher.textScaleFactor;

  @override
  void didChangeTextScaleFactor() {
    setState(() {
      _lastTextScaleFactor =
          WidgetsBinding.instance.platformDispatcher.textScaleFactor;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Text('Current scale factor: $_lastTextScaleFactor');
  }
}

Screenshots or Video

Screenshots 1. Update font size to Large: Image

Open new tab in normal chrome until the text scale is not updated:
Image

Press refresh:
Image

Logs

Flutter Doctor output

Doctor output
flutter doctor -v
[✓] Flutter (Channel stable, 3.35.7, on Ubuntu 25.10 6.17.0-6-generic, locale en_US.UTF-8) [42ms]
    • Flutter version 3.35.7 on channel stable at /A/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision adc9010625 (3 weeks ago), 2025-10-21 14:16:03 -0400
    • Engine revision 035316565a
    • Dart version 3.9.2
    • DevTools version 2.48.0
    • Feature flags: enable-web, enable-linux-desktop, no-enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-lldb-debugging

[✓] Chrome - develop for the web [13ms]
    • Chrome at google-chrome

[✓] Connected device (3 available) [212ms]
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 142.0.7444.134

[✓] Network resources [334ms]
    • All expected network resources are available.

• No issues found!

Activity

  1. tirth-patel-nc commented on Nov 11, 2025

    @tirth-patel-nc
    Member

    @asaarnak thanks for the report. Please confirm whether #178271 resembles your case?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Nov 11, 2025
  3. asaarnak commented on Nov 11, 2025

    @asaarnak
    ContributorAuthor

    @tirth-patel-nc
    Yes. onTextScaleFactorChanged not firing on web, but works on Android.
    Maybe it's related but this issue is about initial textScaleFactor is wrong when app initializes and then needs refresh to update it.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Nov 11, 2025
  5. tirth-patel-nc commented on Nov 12, 2025

    @tirth-patel-nc
    Member

    Thanks for the report. Seeing the same behaviour with latest SDK versions on Web.

    stable : 3.35.7
    master : 3.38.0-1.0.pre-525
    
  6. added
    platform-webWeb applications specifically
    team-webOwned by Web platform team
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    and removed
    in triagePresently being triaged by the triage team
    on Nov 12, 2025
  7. self-assigned this
    on Nov 20, 2025
  8. moved this from To do to In progress in Nevercodeon Nov 20, 2025
  9. moved this from In progress to PR submitted in Nevercodeon Nov 20, 2025
  10. moved this from PR submitted to Done (PR merged) in Nevercodeon Dec 2, 2025
  11. added
    r: fixedIssue is closed as already fixed in a newer version
    on Dec 2, 2025
  12. github-actions commented on Dec 16, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

found in release: 3.35Found to occur in 3.35found in release: 3.38Found to occur in 3.38frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-webOwned by Web platform team

Type

No type

Projects

  • Status
    Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions